PDA

View Full Version : Nokia 3310 and servo motors



yatyas72
- 17th February 2014, 23:09
Can someone take a look at my code and tell me why my RC servos won't move when I use the include LCD_3310v32.inc. If I remove that include the program works as it should. I have a project that I'm working on that could really use the LCD for feedback, without being tethered to a computer via USB port. The program compile and runs just the servos don't move. Again if I remove the Include the servos do exactly as programmed. I'm totally stumped!



DEFINE OSC 48
DEFINE ADC_BITS 8
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 50

'Include "modedefs.bas" ' Include serial modes.
'include "LCD_3310v32.inc"

ADCON1 = %00001011

Pulse var word
TRISA = %00000000
TRISB = %00000000
TRISC = %00000000

Start:
Pulse = 0
PORTB.1 = 1
for Pulse = 1000 to 1500 step 1
PORTC.0 = 1
pauseus Pulse
PORTC.0 = 0
pause 15
next Pulse
PORTB.1 = 0
pause 250
PORTB.1 = 1
for Pulse = 1500 to 1000 step -1
PORTC.0 = 1
pauseus Pulse
PORTC.0 = 0
pause 15
next Pulse
PORTB.1 = 0

PORTB.1 = 1
for Pulse = 1000 to 2000 step 1
PORTC.1 = 1
pauseus Pulse
PORTC.1 = 0
pause 15
next Pulse
PORTB.1 = 0
pause 250
PORTB.1 = 1
for Pulse = 2000 to 1000 step -1
PORTC.1 = 1
pauseus Pulse
PORTC.1 = 0
pause 15
next Pulse
PORTB.1 = 0
Goto Start


All the code does is move two servos through their rotations left and right. It took me two days of troubleshooting to figure out what the problem was. But looking over the include file I still cannot find the problem. I've looked through the forum and haven't found this problem.
Any help is greatly appreciated!
Larry

Darrel Taylor
- 18th February 2014, 02:40
The include file has the statement ...

goto Start ' Jump out to main program (whatever is using this Include).

In your program, Start is after the ADCON1 and TRIS statements.
Those lines don't get executed, therefore your servo's won't work.

yatyas72
- 18th February 2014, 21:29
Darrel,
Thanks for explaining that. I had read that while looking through the code and it just didn't hit me. I had downloaded the V4 code last night and that doesn't have that line in it. Worked perfectly.
Thanks for your help!
Larry