Hi Bruce,
Here it is. Basically driving a H-Bridge with 2 inputs and an enable.
Hope this helps. The analog input and sleep interrupt is derived from one 0/12V signal, hence stepped down.
Thanks
Hi Bruce,
Here it is. Basically driving a H-Bridge with 2 inputs and an enable.
Hope this helps. The analog input and sleep interrupt is derived from one 0/12V signal, hence stepped down.
Thanks
It would help if you hard part values and part descriptions along with voltage levels at
various nodes in your schematic, but what is connected to the center node entering R1?
Which state change are you expecting to wake the PIC from sleep? If you're not testing for
this before entering sleep, you have no idea what level transition causes a wake-up. May
or may not be important. Just curious.
Also, if you're just testing for 0-5V why not just use a digital input VS an A/D?
With 10-bit resolution testing for potvalue >=250 is testing for >=~1.22V. Is the voltage in
on GPIO.0 and GPIO.5 below the input threshold levels?
Note: You still need to disable global interrupts. It will jump to location 4 on the 1st wake-
up so you'll be executing code from somewhere unexpected after the 1st wake-up. If it
does make it through that somehow global interrupts will be disabled on the 2nd pass, but
it's still not going to be working like you expect.
Bruce,
Thanks for looking and for some good points.
The bridge voltage (R1/R2) is either 0V or 4V. I used analog as I may need to be flexible on the voltage values later on.
The sleep operation does work fine, but I have disabled global interrupt at the start now.
The problem is that GP4 sometimes goes high of its own accord on switching on. The length of time it stays on varies, after that operation is as I intended. Is this a boot up procedure I have not reckoned with?
Also, have I assembled the bytes of the 10bit A/D correctly?
Cheers
Your A/D part looks fine. If GPIO.4 is going high on power-up, it's most likely due to you
not initializing the port latches before writing to the tris register. Port latches are unknown
at power-up so it's a good idea to set the port to whatever you want 1st then write to the
tris register.
I.E. GPIO = 0 followed by TRISIO = whatever. Then you know the pins that are outputs will
be at a certain logic level at POR.
You have trisio = %00101001, a few other init lines, a pause 1000, then you write to the
port. You have no idea what value is on the output pins until you write to the port after the
pause 1000. Which may not be good with your outputs controlling a motor!
Note: Reading or writing to a port does not clear the interrupt on-change flag. This will just
end the miss-match condition, which then allows you to manually clear the flag.
Read the port, then clear the flag, then enter sleep. That may help.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Thanks Bruce, thanks Joe.S.
The project is now working. I hope this is useful to others too.
It's a good forum.
Cheers
macinug
Bookmarks