Propeller output pin voltage variation
I'm a hobbyist working with the propeller proto board for the first time. I've connected a propeller pin directly to an input of a ULN2003A in order to drive a relay. I wrote some simple test code that switches the relay on and off on 2 second intervals. It appears to be working except that randomly the voltage of the propeller output pin (when the pin is high) drops to 1.64v rather than the normal 3.3v. This in turn prevents the relay from engaging. I've tried this with different pins on the same board and get the same result. Do I need components between the prop pin and the input to the ULN2003A or could I just have a bad proto board?
Comments
If the relay uses the same power source as the protoboard, there's a strong chance that the power surge from the relay switching is pulling the source voltage below what's required to drive the regulators (which I think is 6v). Putting the relay on its own power supply, or putting a large-ish capacitor across the power leads of the supply to the relay may help to buffer the initial surge.
That said, I'm surprised it didn't brown out and reset if that's what's actually happening. To test it, try measuring the voltage going into the prop.
You may get better answers if you can take a picture of your setup and post code. There are a lot of smart people on here.
When I can get 3.3v out of the prop pin it appears to work, but what would you recommend instead?
Someone already asked about posting the code. It would help to see if there is something in the software that is causing it. What are you using for the clock soruce? Is it the standard 5Mhz crystal on the board or something else?
Robert
It probably won't drive it reliably. Check the data sheet!
CON
_xinfreq = 5_000_000
_clkmode = xtal1 + pll16x
_pinOn = 1
_pinOff = 0
_input = 0
_output = 1
_buttonUp = 0
_buttonDn = 1
VAR long SmokeStack[128] ' Stack for smoke sequencer
byte LocalCog
PUB Start(pinNo)
Stop
LocalCog := cognew(SmokeSequence(pinNo), @SmokeStack) + 1
PUB Stop
if LocalCog
cogstop(LocalCog~ - 1)
PRI SmokeSequence(pinNo) | mycount
' Initialize two second counter
mycount := clkfreq*2 + cnt
dira[pinNo] := _output
outa[pinNo] := _pinOn
' Toggle relay on/off every two seconds
repeat
if cnt => mycount
outa[pinNo] := !outa[pinNo]
mycount := clkfreq*2 + cnt
The clock is a number from 0 to (1<<32 - 1), so in PASM the clock wraps every 52 seconds, but Spin treats all longs as signed, so the sign changes every 26 seconds.
You may want to use waitcnt( clkfreq * 2 + cnt ) instead of the repeat loop. It's also a little more power friendly, as the chip will go into a lower power wait state. If you're seeing the pin toggling from 0 to 1.6v instead of 0 to 3.3v it may not be your issue.
Here are the relevant sections of the ULN2003A and Propeller datasheets, and I don't see a problem driving the '2003A with the Prop, so long as the load current requirements aren't too high.
Even with a 17V input, the '2003A draws a maximum of 1.35 mA. And even with a 10 mA load, the Prop pin will be at least 2.85V above Vss.
Where's the problem? I don't see it.
-Phil
I used waitcnt instead and the problem has gone away. I would not have suspected is was a software problem. Thanks so much for your help.
It is marginal at higher currents. This is on the first page:
I don't think it is intended for 3.3V inputs.
I still don't see the problem. Even the first page includes TTL devices which may not even reach 3.3V on their outputs. Granted, it does say "5V CMOS devices", but this datasheet was probably written back when most CMOS devices couldn't source much current. Times have changed -- especially given the Prop's output current capabilities. I stand by my observation based on the DC specs, not the front-page boilerplate.
-Phil
If the clock starts at zero, after 13 iterations of your loop, your myCount will be slightly above $7BFA4800 (13 x 160million). Say it's $7C00_0000 for the sake of argument. When that IF statement succeeds, you add 160 mil to it, and it becomes $8589_6800, which Spin treats as -2,054,592,512.
So now you have the system counter at $7C00_0000 (still a positive number), and your myCount value at $8589_6800 (a negative number). The next iteration of your loop succeeds again, because cnt >= myCount, toggling the pin. It adds 160 mil to myCount again, making it $8F12_D000... and so on. This will continue until myCount catches up to cnt, or cnt becomes negative, whichever happens first, all the while toggling your output pin.
On a digital scope you'd see the toggle, but on a voltmeter it'll look like 1.6v instead of 3.3v because it's just reading the average.
Make sense?
I would suggest checking that 6.5V regulator output voltage. It may be a simple overheating/shutdown issue.
This appears to be exactly what is happening. The first failure occurs >= 13 iterations, but subsequent failures occur at exactly 13 iterations. Thanks again.