I have a pretty simple process that I need carried out via a 16F88 and a servo.
I have an arm that has a heating element on the tip of it. I need this heating element to be lowered onto a bed of grass for one second, then lifted out of the grass. I am testing the flammability of grass within a climate controlled wind tunnel. I want this to be triggered from a simple push of a NO button, then have it carry out the whole process from there. Problem is that I have not messed with a servo motor before and I am not sure if I am controlled it in the correct way. The button is on A0 and the servo control output would be on A1. What I have for code is
Is this the correct way of doing it? Any help/suggestions would be great!Code:'Set internal clock settings for 16F88 Define OSC 8 OSCCON.4=1 OSCCON.5=1 OSCCON.6=1 'Turn off A/D conversion ANSEL=0 'Define variables and pins I VAR BYTE BUTTON VAR PORTA.0 SERVO VAR PORTA.1 'Continuous loop until triggered by ignition button buttonloop: If (BUTTON=0) Then goto buttonloop Pause 10 If (BUTTON=1) Then goto positionloop goto button loop 'Servo position control loop positionloop: Pulsout PORTA.1, 100 'pulse to servo for a length of 1 ms to rotate servo CCW certain number of degrees For I=1 TO 100 'pulse to servo every 10 ms for a total of 1 second Pause 1000 NEXT Pulsout PORTA.1, 150 'pulse to servo for a length of 1.5 ms to move to "zeroed" position goto buttonloop End 'end of program never reached
-Marcus




Bookmarks