SX28 Edge Detection
Hi, I hope I am not asking a question that has already been answered. Currently I am working with a SX28 that reads standard PWM from a radio controller receiver (the same signal to drive standard servos). The SX28 takes the duty cycle from the input and creates a proportional PWM at the output to drive a DC motor.
The issue is not with the code but more with the hardware. The SX28 has a bit of trouble detecting edges when the receiver is connected directly to the inputs. I used both TTL and CMOS logic levels. To assist, I placed a non-inverting op amp between the RC receiver and the SX28. The op amp gives enough gain to raise the RC receiver output voltage from about 3.5V to a solid 5V. However, the SX28 will only detect the edges when I place the inputs in Schmidt trigger mode, which probably is a good idea anyways given the noise in the RC receiver system.
Yes, the system now works, but I am wondering if the SX28 is picky about how "edgy" the input pulses are when using the edge detection register. The slew rate of the op-amp I am using is not very good, and I am curious if this is the cause.
Thanks for any input.
The issue is not with the code but more with the hardware. The SX28 has a bit of trouble detecting edges when the receiver is connected directly to the inputs. I used both TTL and CMOS logic levels. To assist, I placed a non-inverting op amp between the RC receiver and the SX28. The op amp gives enough gain to raise the RC receiver output voltage from about 3.5V to a solid 5V. However, the SX28 will only detect the edges when I place the inputs in Schmidt trigger mode, which probably is a good idea anyways given the noise in the RC receiver system.
Yes, the system now works, but I am wondering if the SX28 is picky about how "edgy" the input pulses are when using the edge detection register. The slew rate of the op-amp I am using is not very good, and I am curious if this is the cause.
Thanks for any input.
Comments
· It is probably the noise that is causing false edges to be detected.
· In TTL mode the threshold level is 1.4V. So for the short amount of time that the signal is going from 0 to 5 (or 5 to 0) and is at the 1.4V level any amount of noise will be seen as a bunch of edges.
· The Schmitt trigger mode is the way to avoid this.
· Also the gain in the op-amp circuit is probably causing the noise to be amplified too. If you could run the SX at 3.3V you could avoid using the op-amp, but that still may not solve the problem. Maybe you could use a schmitt triggered gate instead ?
· If you could post you code we might be able to give a better solution.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There is a fine line between arrogance and confidence. Make sure you don't cross it...
Post Edited (Bean (Hitt Consulting)) : 2/27/2009 1:28:34 PM GMT
Here is the code. It should be noted that I am using the PWM from the RC receiver as the inputs for both RB.0 and RB.1. The idea was to have one port for rising edge and one for falling. Maybe it would be better to use one port and continuously change its edge direction at run time? Thanks
But any input on cleaning up my code would be appreciated too. This piece will be a two motor driver that differentially controls a pair of motors. It will respond off two RC inputs.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Bad spellers of the world untie!
Yes I am.
What I can suggest is to download this http://forums.parallax.com/showthread.php?p=541621·into your SX and input the same signal that fails with your code.· This code is Gunther's dual pulse stretching app. which ouputs a 8ms. pulse after detecting an input pulse.· It uses similar code to yours, but doesn't ouput a proportional pulse.
let us know what you find.
Kevin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Bad spellers of the world untie!
On one hand, the results don't make sense because a change to 0 to 1 or 1 to 0 is still an edge. However it may make sense since I am not sure of the specific architecture of the SX. It also may have been due to me splitting the signal to two inputs. I modified my program to use only one input. I change the edge detection now during runtime. I will report if the issue still exists with a non-split input.