R/C receiver to 16F88

Status
Not open for further replies.

Hank Fletcher

New Member
Alright, so I'm trying to get my head around the best way to interface a cheap, hacked R/C receiver to a 16F88. The receiver is powered by a 1.5V battery, and I've got the 16F88 running from a separate, 5V regulated, plug-in power supply. I suppose the 16F88 will eventually be running from a 7805 from a battery pack, but that's where I am right now.

Anyway, the receiver has six leads:
- 1.5V+
- common
- the lead originally intended for forward
- the lead originally intended for reverse
- the lead originally intended for left
- the lead originally intended for right

The "left" and "right" leads have their own problem sorting out, but I haven't quite gotten to that point yet. I'm anticipating that once I sort out things a little better with the "forward" and "reverse" leads, sorting out the second two might become more obvious.

The trick is, the forward and reverse leads constituted essentially an h-bridge for the original motor, each lead attached to an opposite pole on the motor. With the original controller stick at centre, there's no potential difference between the two leads, but both are +1.5V with respect to common. So a voltmeter connecting the two leads reads:
0V when the controller's stick is centred
1.5V when the stick's pressed forward
-1.5V when the stick's pressed backward.

My original idea was to connect the receiver's and battery's common to the power supply's common, and to connect the forward and reverse leads each to their own A/D pin on the 16F88 (with pulldown resistors to common). That way I could use the A/D pins kind of like they were digital inputs, and just check when they change to somewhere closer to 1.5V than 0V. Obviously the problem is that that works when the stick is pressed forward, but doesn't work for when the stick is pressed back.

What can I do for the -1.5V reverse lead? For a long time I was fussing over the best way to do this without frying something and with the least amount of parts. If I use a pullup resistor on the reverse leads A/D pin instead, should I expect it to sink the voltage a bit, and be able to read when the A/D pin drops a bit below the supply voltage? Looking at the breadboard and the aforemention description of what's going on, I couldn't figure out if that would risk shorting something somehow.

Am I going about this the wrong way with the battery and power supply? I know this makes my noobness obvious, but I couldn't figure out either what I need to do to drop the regulated 5V for the 16F88 so that I could have the 1.5V for the receiver on the same circuit, hence the battery. I mean, does a voltage divider work on a regulated circuit? I've fried some pots in the past, I think because I didn't take into account the "regulated" characteristic of the circuit, but that's always been a bit of a mystery - I don't fry components if I can help it!

Sorry for the wordy description. I'd post a schematic of it if someone tipped me to some freeware schematic drawing software!
 
Last edited:
You are trying to get a PIC to read the outputs of the receiver, right?

What model R/C receiver? Toy-grade or hobby grade? If it's hobby-grade, then your pinouts and description are all wrong (mainly because of all the negative output voltage stuff and how you need 2-pins each for fwd/rev and left/right instead of just one).

Now, to blindly answer your question- use optoisolators to isolate those postive and negative voltages outputs of the receiver so you can re-reference them to ground however you like (making them positive, for example). For example, you could take two optocouplers and connect their LEDs in anti-parallel with each other (with current limiting resistors of course) and connect both of them up so current runs between the receiver's fwd/rev outputs through the opto LEDs. If the voltage was one polarity, one opto LED would light, if the voltage was reverse polarity, the other Opto LED would light. If there was zero voltage difference, neither LED would light (and both opto outputs would read high...or low, depending on the pull-up/down resistor you used). You use the LEDs inside the optos almost as rectifiers, but you don't use the "output" of the rectifier, rather you use the voltage drop across the diodes (which cause it to light up and trigger the photo-detector). YOur voltages are too low relative to the diode forward voltage drops to use a normal rectifier.

You could also "dedicate" each optocoupler LED to each receiver output and connect the other end of the LED to ground. It each would only "pay attention" to one of the receiver output in the fwd/rev pair, unlike the first method where it pays attention to both simultaenously (ie. if for some reason both lines went +1.5V or -1.5V at the same time, it would behave differently than the anti-parallel method).

You could use a resistive divider to turn a regulated 5V into a lower voltage. It would be REALLY crappy though and the "output voltage" would change with the current draw. The prime problem with a resistive divider as a power source is high output impedance (causing voltage to change greatly with current) when using large resistance values, or high power dissipation between the power rails when using low resistance values (that's why you fried the pots).

It would be far better if you used an LM317 and adjusted it down to 1.5V (near it's minimum capability I think), or use an op-amp unity buffer and feed a resitive divider to it's input (and power both from the regulated 5V). If the op-amp has enough output drive it can act as a regulated supply for the receiver.

Plus radio equipment like receivers doesn't work with crappy power sources, especially ones where output voltage is highly dependent on output current.
 
Last edited:
Couldn't you just run the negative signal(s) thru an inverting buffer? Then if you level shifted the output(s) by 1 AA cell, you could read as digital. Perhaps the same with the left and right output.
 
nickelflippr said:
Couldn't you just run the negative signal(s) thru an inverting buffer? Then if you level shifted the output(s) by 1 AA cell, you could read as digital. Perhaps the same with the left and right output.

THe inverting buffer would require a negative voltage supply which is PITA. That's why I suggsted optos.
 
You are trying to get a PIC to read the outputs of the receiver, right?
Yep. It's working, but not 100% on form yet.

What model R/C receiver? Toy-grade or hobby grade?
Toy grade, and somewhat unconventional at that. The receivers out of the Zip-Zap micro racers Radio Shack used to sell - got 'em surplus at Liquidation World. So on one board, there are the power leads to the 1.5V Li rechargeable battery (of done away with that and have a D alkaline cell I'm using for this testing stage), and the leads for the motor and steering - the 1.5V battery's meant to power the whole kit'n'kaboodle, even in the original design! The leads for the motor are powered to connect directly to the motor (they're small motors, like smaller than most pager motors I've seen), so it's an h-bridge coming right off the receiver board, as oppose to just lower current signal wires to a separate motor circuit.

The steering... don't get me started! The Zip-Zaps are too small to even have the small dc motor that usually actuates the front wheels of cheap, larger R/C toys. What the Zip-Zaps have instead is an electro-magnetic set-up, so the original leads coming off the receiver board for that were super thin coil wire. Pretty cool solution for a small toy when you think about it (the Zip Zaps are lotta fun, especially at liquidation prices!), but I've since replaced the thin wire with more robust leads. The power on the steering leads I think I remember were 1.5V, but operated in a funny way with respect to the 1.5V (like they sank 1.5V, or something) but I'm bit fuzzy on what I tested with those - kind of got distracted with sorting out the motor leads first. I'm confident that I'll be able to figure out how to manipulate the steering leads if I can just get the motor leads sorted out first.

Now, to blindly answer your question- use optoisolators to isolate those postive and negative voltages outputs of the receiver so you can re-reference them to ground however you like (making them positive, for example).
I don't have any optoisolators on hand, and the only place that sells that stuff around here does so with a price that makes it obvious that it's the only place that sells stuff like that around here, if you know what I mean!

Am I beating a dead horse here? It just seems like I'm a couple brain cells short of realizing an obviously simple solution!
 
dknguen said:
Ha! Believe it or not, I actually had to look that up. I was kind of thinking "I need an inverter here," at one point, too. But can't I just effectively do that in my PIC program by pulling-up the A/D pins to V+, and sinking them by 1.5V when the leads are actuated?
 

I can't think of a transistor + pull resistor configuration that will output a 0-5V signal when the input signal is 0 to -1.5V. BUt maybe you can think of something. My last best guess was something involving a pull-down transistor with a pull-up PMOS. You might have trouble turning it off though...

But if you can't get your hands on optos, or can't get the "pull-down resistor, pull-up PMOS" to work (the problem I see isn't turning on the PMOS but turning it off with a gate voltage of just 1.5V when it is tied to 5V, or even 3V), then perhap's Nickel's method of the inverting amp is best. Perhaps a 555 timer charge pump would suffice for providing the negative supply. I still think it's easier just to get optos though.

It might be possible to use an AC pass-capacitor to filter out the DC of the receiver outputs and then bias the signal at 2.5V on the "PIC side" of the capacitor with two equal valued resistors between the power rails so that the ADC can read it. However, you wouldn't see DC signals. You would see the + or - "spike" (about 2.5V or whatever you biased it to) whenever the receiver changed states and then it would settle back to zero. You would have to make the PIC remember the last polarity spike it saw and make sure the ADC is able to catch the spike in time before it decays.

Do you understand what I mean when I say AC filter capacitor and then DC bias the AC signal with two resistors? It's used all the time in BJT amplifier circuits.
 
Last edited:
Do you understand what I mean when I say AC filter capacitor and then DC bias the AC signal with two resistors? It's used all the time in BJT amplifier circuits.
Kind of - I'm almost there. Can you post a link if you find one that maybe describes it with a schematic?
 
If you think about it what you have a 2 trinary bits. Each can be neg, off, or, pos.

All you need is one to transfer data. But since our logic is binary you need two input bits to read it.

EDIT: If you use a UART (software or hardware) you could transfer the data using just just the + side of one channel. No need to invert or opto isolate. Not sure what speed you can switch the Xmiter at.

If you want to go with a sync method you could use the off state to deliminate bits and the + and - for 1's and 0's.
 
Last edited:
This is a follow-up for what I decided what to do.

After much puzzling, I decided that the best thing to do was to keep it simple. I connected each h-bridge output to its own A/D pin, and that's it. No pull-up or pull-down resistors, just A/D pin to lead. +V of the receiver comes from the +1.5V battery, with the battery and receiver commons connected to that of the PIC.

What that means is, the A/D pins each read +1.5V when the controller is in centre position. When either forward or backward is press, the respective lead sends the A/D down to common, but the pin bounces up really well when the control stick is released (no floating problems). I adjusted the programming accordingly, so that the PIC detects when each A/D pin drops close to ground.

The only defect with this solution is that it means the leads are using power when the controller is in a static position. Considering the power used is only as little as is require by the A/D pins, I figure it's not too much to get worked up about. It's not electronics according to Hoyle, but I guess you're prone to break rules with hacking projects anyway!

That's the forward and reverse done, now for the left and right. When I get that sorted, I'll probably post a Youtube video. Thanks for helping work through this!
 
Last edited:
To simplify the programming and speed it up, you could use the comparators in mode 2 with Vref set to 0.75V.

Mike.
 
To simplify the programming and speed it up, you could use the comparators in mode 2 with Vref set to 0.75V.

Mike.
How's that again? You know something about the 16F88 I'm clueless about, which admittedly is not something hard to do! I'll have to hit that datasheet again...
 
Last edited:
If you set CMCON=2 and CVRCON to 0xa4. A value less than 0.8V on RA0 will set bit 6 of CMCON and <0.8V on RA1 will set bit 7. You can also test RA2 & RA3 if needed.

Mike.
Edit, corrected polarity.
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…