Steering a dolly by means of a black line<

Satchid

Member
Hi,

I am a little desperate. I a

here is the Hardware.

It is The steering part that bugs me.

I made a triangular 3 wheel Line following dolly (90cm X 120cm) and the front wheel is the steering wheel. It is belt driven from a stepper motor via a belt in full step mode. The stepper needs to do 350 steps from middle to full left and from middle to full right. (from left to right 700 steps.)

There are 6 sensors 10mm apart on a 15mm wide black line on a white background.

I have made a program But I just cant get is to work properly. could one of you have a look pleas.

Here is de code

Code:
 ;Line following Buggy
 
 '28x2
' picaxe pin assignment for stepper driver inputs
' enablepin = pinC.0
' Dirpin = pinC.1  -> High - CCW, Low - CW
' Clckpin = pinC.2
' MS0pin = pinC.3
' MS1pin = pinC.4
' MS2pin = pinC.5

' Full stepping - MS0,MS1,MS2 low  -> for high speed
' 1/16th stepping - MS0, MS1, MS2 high - for tracking speed
' 1/8th stepping - MS0 high, MS1 high, MS2 low - for low speed slew
setfreq m16
#picaxe 28x2 'Identify the PICAXE being used as an 14M2.

#no_data 'Prevent data from being downloaded to PICAXE._
       
    symbol sen1_in   = 0 'Assign symbol sen1_in to anlog input 0
    symbol sen2_in   = 1 'Assign symbol sen1_in to anlog input 1
    symbol sen3_in   = 2 'Assign symbol sen2_in to anlog input 2
   
    symbol sen4_in   = 3 'Assign symbol sen3_in to anlog input 3
    symbol sen5_in   = 9 'Assign symbol sen19_in to anlog input 9
    symbol sen6_in   = 11 'Assign symbol sen11_in to anlog input 11

;Values of the inputs of IR sensors  1 2 3 4 5 6.   
     
    symbol sen1_val  = b1 'Define variable sensor values "sen1_val = b1
    symbol sen2_val  = b2 'Define variable sensor values "sen2_val = b2
    symbol sen3_val  = b3 'Define variable sensor values "sen3_val = b3
    symbol sen4_val  = b4 'Define variable sensor values "sen4_val = b4
    symbol sen5_val  = b5 'Define variable sensor values "sen5_val = b5
    symbol sen6_val  = b6 'Define variable sensor values "sen6_val = b6
   
    symbol level     = b9 ;Define mean value of sensors
   
            ;below are the different positions of the stepper positions.
            ;coresponding to the sensors R50 is middel position for straight
            ;forward movement. R0 most left position of steering wheel and R100
            ;is most right position of steering wheel.           
    symbol R0        = w9  ;angle of stepper (steering wheel) set in number of steps
    symbol R10         = w10 ;angle of stepper (steering wheel) set in number of steps
    symbol R30         = w11 ;angle of stepper (steering wheel) set in number of steps
    symbol R50       = w12 ;angle of stepper (steering wheel) set in number of steps
    symbol R70       = w13 ;angle of stepper (steering wheel) set in number of steps
    symbol R90       = w14 ;angle of stepper (steering wheel) set in number of steps
    symbol r100      = w15 ;angle of stepper (steering wheel) set in number of steps
   
            ;oldpos and newpos is broagt in to know the movement direction.
   
    symbol oldpos    = w17 'remember previous position of stepper in number of                 steps
    symbol newpos    = w18 'remember new position of stepper in number of steps
   
               
    symbol motor     = c.2 ;motor output c.2
    symbol motor_dir = c.1 ;motor direction HIGH IS FROM LEFT TO RIGHT c.1
                     ;LOW IS FROM RIGHT TO LEFT
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ; EXPLANATIONS ARE IN THE SYMBOL AREA
 
 
 ; PROGRAMS
 ; steering wheel starts in midle and is set to midle position 50 multyply
 level = 110     ; =((210-10)/2)+10
 
     R0        = 650 ;Ro to R100 max setings gor that sensors
    R10        = 790
    R30        = 930  ;with 0 in next line this line shoud be -70.
    R50       = 1000 ;should be 0 but picaxe is not alowing - like -70 in previous line
    R70       = 1070
    R90       = 1210
    r100        = 1350
   
 mainloop:
 
     readadc  0,sen1_val; read sensors an place in storage ,sen1_val;
     readadc  1,sen2_val; read sensors an plase in storage ,sen2_val;
    readadc  2,sen3_val; read sensors an plase in storage ,sen3_val;
     readadc  3,sen4_val; read sensors an plase in storage ,sen4_val;
     readadc  9,sen5_val; read sensors an plase in storage ,sen5_val;
     readadc  11,sen6_val;read sensors an plase in storage ,sen6_val;
   


        ;there are alwais 2 sensors higher than "level" if they are on top of the line.
        ;below is testing witch 2 are just that.
    If sen1_val >= level and sen2_val >= level then goto test_sens1_and_2 ;is stepper position here?
    If sen2_val >= level and sen3_val >= level then goto test_sens2_and_3 ;is stepper position here?
    If sen3_val >= level and sen4_val >= level then goto test_sens3_and_4 ;is stepper position here?
    If sen4_val >= level and sen5_val >= level then goto test_sens4_and_5 ;is stepper position here?
    If sen5_val >= level and sen6_val <= level then goto test_sens5_and_6 ;is stepper position here?

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

        ;if newpos (new position) is lower than the old position then the stepper went from
        ;right to left. and visa versa.
test_sens1_and_2:        ;if 1 & 2 are over the sensor than
    if newpos = r0 then goto mainloop     ;if new pos is R0 then goto begin and start again.
    If newpos < oldpos and newpos > r0 then goto turnleft ; explanation on top of this section.
    if newpos > oldpos and newpos < r10 then goto turnright   
    if newpos = r10 then goto mainloop ;;if new pos is R10 then goto begin and start again.

test_sens2_and_3:       
    if newpos = r10 then goto mainloop
    If newpos < oldpos and newpos > r10 then goto turnleft
    if newpos > oldpos and newpos < r30 then goto turnright   
    if newpos = r30 then goto mainloop   
       
test_sens3_and_4:    ;midle position   
    if newpos = r30 then goto mainloop ; this is center of movement
    If newpos < oldpos and newpos > r30 then goto turnleft
    if newpos > oldpos and newpos < r50 then goto turnright   
    if newpos = r50 then goto mainloop
   
test_sens4_and_5:       
    If newpos = r70 then goto mainloop
    If newpos < oldpos and newpos > r30 then goto turnleft
    if newpos > oldpos and newpos < r50 then goto turnright   
    if newpos = r90 then goto mainloop
       
test_sens5_and_6:       
    If newpos = r90 then goto mainloop
    If newpos < oldpos and newpos > r70 then goto turnleft
    if newpos > oldpos and newpos < r90 then goto turnright   
    if newpos = r100 then goto mainloop   

   
 turnLeft:
 oldpos = newpos ;set old pos to new position
  high  motor_dir ; change direction of motor
 newpos = newpos -1 ;if running to the left, than the step related to the center decrease leaving
               ;the oldposition to be the previous new position.
 goto stepmotor
 return
 
 turnRight:
 oldpos = newpos    ;set old pos
 
 low motor_dir ; change direction of motor
 newpos =  newpos +1 ;if running to the left, than the step related to the center decrease leaving
                ;the oldposition to be the previous new position.
 goto stepmotor
 return

 Stepmotor:

    high motor    ;high and low pin c.2 to form a pulstrain to stepper
    pause 2
    low motor    ;high and low pin c.2 to form a pulstrain to stepper
    pause 1
goto mainloop
 
Last edited:

hippy

Technical Support
Staff member
I have made a program But I just cant get is work properly.
It might help if you could describe what the program is not doing which it should be doing, or what it is doing which it should not.

It may also help to describe the principle of operation, how the algorithm is intended to keep the buggy on the desired track. A brief overview of the intended operation will save people from having to reverse engineer what the program is meant to do, which may be difficult if it is not working as intended.
 

erco

Senior Member
Satchid: Are your sensors fixed to the chassis? That will complicate everything. If you mount them ahead of and rotating with your front steering wheel, then control is a simple matter. Just steer the wheel/sensor assembly to follow the line and keep the line centered. Line sensed left=steer left. Easier with a servo than stepper, as shown at https://www.youtube.com/watch?v=z8wlRBLfAQo
 

Satchid

Member
Erco, that principle is exactly what i am making. How could I achieve that. How could the program look like.

Hippy, I was writing and suddenly (I must have pressed a wrong key) it went away unfinnished. ans it is not allways easy fore me to explain things as I would like to. But thank you Hippy, for you to allways there to help.
But In the youtube link ( https://www.youtube.com/watch?v=z8wlRBLfAQo ) from Erco's post it says what I am trying to make.

I have the sensors plased on the chassis, but can easily move them to the steering wheel. But I have no idea of how to make a program for it.
 

Satchid

Member
Hi Hippy, Erco et all.

Here is than an explanation of what I would like and tried to program.

I have build, as said above, a Tricycle robot of larger size.

Now I need it to follow a black line as close as possible The sensor is on the chassis.

I need for a full left to right movement of the steering wheel 700 steps of a stepper motor.

Above a black line are 6 sensors to know where the line is situated and to steer the steering wheel in the appropriate direction.

With the 6 sensors I can detect 10 position on a 15mm wide line under the sensor. The picaxe can detect as follow: 1, 1&2, 2, 2&3, 3, 3&4, 4, 4&5, 5, 5&6, 6, The program That I made takes only the position like 1&2 in account.

Now i would like the steering wheel to follow the position of the sensed line, if the sensors move to the left then the wheel tray's to correct that, and if it go's even farther to the left, then the steering will correct that by by turning even more. Every space between the sens positions (between 1 and 1&2 for instance) is 700/10 = 70 steps. The middle of the sensors is 3&4 therefore taking it as 0 steps. If now the line turns to the left under sensor 3, then the line is only 1 space of the middle, therefore turning only -1 X 70 steps to the left till the line is above the middle again. Then if the line sensor moves farther away, say to 1&2, then the wheel turn -4 X 70 = -280 steps.

In short I would like the steering wheel to move proportional to the line under the sensor. if the line is little away from the straight position, then the steering wheel is turning a small angle, If the line is far away from the center then the steering wheel is turning a bigger angle.

I foresee problems with this movement in the respect of when it is moving to the left or the right, and suddenly it starts moving to the other direction, then the picaxe might not know in what direction the wheel should steer. It should know from where it comes. Therefore I introduced the oldpos (old position) and the newpos (new position) in my program: if oldpos is smaller as newpos, then the previous move is from left to right. maybe I do not need this.


Hippy I tried my best to show you what my intention is.

But the Idea of Erco might be easier if i see it correct. Could i see it like this? If i put the sensor in the front of the steering wheel with sesor 3&4 in the centerline of the dolly, then the steering wheel is trying to stay on the line?
 

erco

Senior Member
Here's a different trike line follower of mine. It uses one laser sensor which steers with the front wheel. You can see the laser dot on the black line. This is actually following the edge of the line. It's always oscillating because there's only one sensor, at least two are required to not oscillate. More is better, to allow smoother and faster tracking. If you have 3 or more moving sensors (attached to your steering wheel) and your steering motor is fast and your vehicle/dolly speed is slow, then your code can be very simple. Read your sensors and determine if the line is in the center of your sensor array, or to the left or right.

DO
If line is left of center, steer left a bit.
If line is right of center, steer right a bit.
If line is on center, do nothing.
LOOP

 

mikeyBoo

Senior Member
hi erco,
Nice job on the line following 'bot. This looks like a perfect application for a PID loop that controls an RC servo. I haven't been able to find code for doing PID on a Picaxe on the forum (lots of suggestions). Has anyone coded a decent PID for Picaxe ?? Ideally an 08M2 that takes an analog input & outputs a servo pulse (for steering) or PWM (if using a DC motor) (i.e. a canned PID control module). Lots of possible uses, but I don't wanna' write the code if one of y'all has already figured it out.
Here's a link to a nice 3x PID chip, but the Picaxe interface coding might be a little challenging:
IC-PID-03 : (Only the Chip) Three Channel PID / PWM / ADC Controller IC $30
http://www.cyberdata-robotics.com/IC-PID-Controller
Once again, anybody written a decent PID procedure for the Picaxe ? I'm busy being retired (still trying to figure out "fish logic"), so don't wanna' re-invent the wheel.
 

Satchid

Member
Yes, My steering wheel is driven.

I am using a polulu 8sensor analog sensor board. But playing around for the moment with 6 of them.
 

erco

Senior Member
Excellent, a steered and driven wheel is best.

The overall speed limiter for your system will be your steering stepper motor. Most steppers are quite a bit slower than servos, so you need to get that moving as fast as you can. When in doubt, increase voltage for higher speed! :)
 

Satchid

Member
Hi All,
I am taking it now more step by step.
I made a new program and test it on a stepper motor. It works fine, but the motor is slow, even in full step mode. This is because the coplete program has to be repeated to make 1 puls.
I want the stepper position known at all times its step count.
I i could step the motor via PWMout on c.2. But I need the number of pulses count that it runs left or right. (not pulse per sec or so) I looked into the count comand. I could count for 5 seconds but I am aftaid that the count command only put the result down after it stops counting. That makes it unusable for this purpose becouse i need the count at every moment.

I see this as a solution, I might pull a wire from the pwmout pin to an input pin and count the number of Hi's on the input pin (c.6). then the result of the count (newpos in the program) could be used in the program.
Question : can I not get the Hi's or Low's from the pwmout from inside without having to pull a wire?

Code:
   ;Line following DOLLY
 '28x2 SHIELD AXE401
' enablepin = pinC.0
' Dirpin = pinC.1  -> High - CCW, Low - CW
' Clckpin = pinC.2
' MS0pin = pinC.3
' MS1pin = pinC.4
' MS2pin = pinC.5
' Full stepping - MS0,MS1,MS2 low  -> for high speed
' 1/16th stepping - MS0, MS1, MS2 high - for tracking speed
' 1/8th stepping - MS0 high, MS1 high, MS2 low - for low speed slew
setfreq m16
#picaxe 28x2 'Identify the PICAXE being used as an 28X2.
#no_data 'Prevent data from being downloaded to PICAXE._
		
	symbol sen1_in   = 0 		'Assign symbol sen1_in to anlog input 0
	symbol sen2_in   = 1 		'Assign symbol sen1_in to anlog input 1
	symbol sen3_in   = 2 		'Assign symbol sen2_in to anlog input 2
	symbol sen4_in   = 3 		'Assign symbol sen3_in to anlog input 3
	symbol sen5_in   = 9 		'Assign symbol sen19_in to anlog input 9
	symbol sen6_in   = 11 		'Assign symbol sen11_in to anlog input 11
	symbol sen1_val  = b1 		'Define variable sensor values "sen1_val = b1
	symbol sen2_val  = b2 		'Define variable sensor values "sen2_val = b2
	symbol sen3_val  = b3 		'Define variable sensor values "sen3_val = b3
	symbol sen4_val  = b4 		'Define variable sensor values "sen4_val = b4
	symbol sen5_val  = b5 		'Define variable sensor values "sen5_val = b5
	symbol sen6_val  = b6 		'Define variable sensor values "sen6_val = b6
	symbol Senspos1   = b10 	;represen a maen read value of on or 2 sensors 1
	symbol Senspos12  = b11 	;represen a maen read value of on or 2 sensors 1&2
	symbol Senspos2   = b12		;represen a maen read value of on or 2 sensors 2
	symbol Senspos23  = b13		;represen a maen read value of on or 2 sensors 2&3
	symbol Senspos3   = b14		;represen a maen read value of on or 2 sensors 3	
	symbol Senspos34  = b15		;represen a maen read value of on or 2 sensors 3&4
	symbol Senspos4   = b16		;represen a maen read value of on or 2 sensors 4
	symbol Senspos45  = b17		;represen a maen read value of on or 2 sensors 4&5
	symbol Senspos5   = b18		;represen a maen read value of on or 2 sensors 5
	symbol Senspos56  = b19		;represen a maen read value of on or 2 sensors 5&6
	symbol Senspos6   = b20		;represen a maen read value of on or 2 sensors 6
	symbol level     = b9 		;Define mean value of sensors 
	symbol R0        = w9 		;angle of stepper (steering wheel) set in number of steps
	symbol R10	     = w10  	;angle of stepper (steering wheel) set in number of steps
	symbol R30	     = w11 		;angle of stepper (steering wheel) set in number of steps
	symbol R50       = w12 		;angle of stepper (steering wheel) set in number of steps
	symbol R70       = w13 		;angle of stepper (steering wheel) set in number of steps
	symbol R90       = w14 		;angle of stepper (steering wheel) set in number of steps
	symbol R100      = w15 		;angle of stepper (steering wheel) set in number of steps
	symbol motor     = c.2 		;motor output c.2
	symbol motor_dir = c.1 		;motor direction HIGH IS FROM LEFT TO RIGHT c.1 000
	;pwmcountin	     = c.6		;input from pwmout wired from c.2
	symbol newpos    = w20		;position of steering wheel.
	; enablepin = C.0
	' MS0pin = C.3
	' MS1pin = C.4
	' MS2pin = C.5
		
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;		
		;P R O G R A M 
			
beginprogram:
	pause 2000
 	newpos is 350 	;is position of steeringwheel when straight forward. 
	level = 150 	; =((210-10)/2)+10
 main:
 	readadc  2,sen3_val; read sensors an plase in storage ,sen3_val;
 	readadc  3,sen4_val; read sensors an plase in storage ,sen4_val;
 	Senspos3   = sen3_val
	Senspos4   = sen4_val
	 
         ;sensor lev is high when over the line
If  Senspos3 > level and Senspos4 > level then goto nothing		;black line
If  Senspos3 > level and Senspos4 < level then goto right 		;black line 
If  Senspos3 < level and Senspos4 > level then goto left		;black line 

goto main
 Left:
	 If newpos = 0 then goto main  ; ends movement when motor has moved 350 steps to the left from middle. 
	 newpos is newpos-1
	 high  motor_dir
  goto stepmotor
 return
 
 Right:
 	If newpos = 700 then goto main ; ends movement when motor has moved 350 steps to the right from middle.
 	newpos is newpos +1
 	low motor_dir
  goto stepmotor
 return

nothing:
goto main

Stepmotor:
	high motor	;high and low pin c.2 to form a pulstrain to stepper
	pause 2
	low motor	;high and low pin c.2 to form a pulstrain to stepper 
	pause 1
goto main
	
 endofcode:
 

erco

Senior Member
Willy: Got your PM but I'll reply here in hopes it may help someone else. That's a complete laser sensor module I posted about at http://www.picaxeforum.co.uk/showthread.php?29407-infra-red-range-sensor&p=304311&viewfull=1#post304311

More on that tricycle robot at http://www.picaxeforum.co.uk/showthread.php?29547-Laser-Trike

You might be able to see some of my article at http://servo.texterity.com/servo/201704?pg=10#pg10

Another neat project using that sensor at https://www.youtube.com/watch?v=95SY0Pk3spE

How big is this dolly of yours? Can you change to a servo? Here's my favorite big, strong, cheap servo: https://hobbyking.com/en_us/vs-11-vigor-extra-large-servo-19sec-19kg-103g.html

My laser trike program is very short & simple, that's the nature of servos. As I said, the steering servo simply moves one way when it senses the line and the other way when it doesn't:

Code:
#picaxe 08m2

servo 0,150 ' steer servo 70=left/155=straight/230=right
servo 1,110 ' drive servo 110=forward/150=stop
'pin c.2 laser sensor no lens  black=1    white=0

do
if pinc.2=0 then let b0=b0-2 min 70 'IF white steer left
else let b0=b0+2 max 230            'ELSE steer right (black)
endif
servopos 0,b0      ' update servo position
pause 10
loop
 
Last edited:

Satchid

Member
Hi,
@Erco
Thank you for the laser info, but the sens distance is to small.

To all,
I need something to detect a IR light at about meter and code to reed that. But it is probably off topic.

Thank you et all for the help so fat.

Willy
 

Satchid

Member
Hi,
@Erco
Thank you for the laser info, but the sens distance is to small.

To all,
I need something to detect a IR light at about meter and code to reed that. But it is probably off topic.

Thank you et all for the help so fat.

Willy
I see, Here is allot missing in this post. I am sorry. This had to be there:

for another part of the dolly I need a steering divice that let the camera point towards one point at 3meter away. The camera is mounted on top of a steppermotor. The camera has to point towards a target wile the camera and the dolly are pollowing the line on the floor. So if the dolly is moving, then the stepper has to turn left or right and thus keeping the camera on the target. I need a sensing system between the stepper and the target.
I taught that your laser sensor could do just that, but the max distanse of that laser sensor is 1.5 meter.

Therefore the confusion. I should have started a new topic for this.
 

erco

Senior Member

Satchid

Member
Erco,
The linefollowing part of the dolly works grate in the front that is. i am making an identical electronic to the rear steering system for the same line to follow.
This is with the sensors undeneat of the 22cm diameter steering wheel.
here is the code
Code:
  ;automatic Line following dolly
 
 '28x2
' picaxe pin assignment for stepper driver inputs
' enablepin = pinC.0
' Dirpin = pinC.1  -> High - CCW, Low - CW
' Clckpin = pinC.2
' MS0pin = pinC.3
' MS1pin = pinC.4
' MS2pin = pinC.5

' Full stepping - MS0,MS1,MS2 low  -> for high speed
' 1/16th stepping - MS0, MS1, MS2 high - for tracking speed
' 1/8th stepping - MS0 high, MS1 high, MS2 low - for low speed slew
setfreq m16
#picaxe 28x2 
#no_data 'Prevent data from being downloaded to PICAXE._
	symbol sen1_in   = 0 'Assign symbol sen1_in to anlog input 0
	symbol sen2_in   = 1 'Assign symbol sen1_in to anlog input 1
	symbol sen3_in   = 2 'Assign symbol sen2_in to anlog input 2
	symbol sen4_in   = 3 'Assign symbol sen3_in to anlog input 3
	symbol sen5_in   = 9 'Assign symbol sen19_in to anlog input 9
	symbol sen6_in   = 11 'Assign symbol sen11_in to anlog input 11
	symbol sen7_in   = 10 'Assign symbol sen11_in to anlog input 10 	
	symbol sen8_in   = 13 'Assign symbol sen11_in to anlog input 13	
	symbol sen1_val  = b1 'Define variable sensor values "sen1_val = b1
	symbol sen2_val  = b2 'Define variable sensor values "sen2_val = b2
	symbol sen3_val  = b3 'Define variable sensor values "sen3_val = b3
	symbol sen4_val  = b4 'Define variable sensor values "sen4_val = b4
	symbol sen5_val  = b5 'Define variable sensor values "sen5_val = b5
	symbol sen6_val  = b6 'Define variable sensor values "sen6_val = b6
	symbol sen7_val  = b7 'Define variable sensor values "sen5_val = b5
	symbol sen8_val  = b8 'Define variable sensor values "sen6_val = b6
	symbol level    = b23 ;Define mean value of sensors 
	symbol motor     = c.2 ;motor output c.2
	symbol motor_dir = c.1 ;motor direction HIGH IS FROM LEFT TO RIGHT c.1
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;		
		;P R O G R A M 
		

		
			
beginprogram:
	pause 2000
 	level =110; =((210-10)/2)+10
	
set_speed:
 		;low c.3	low c.4 	low c.5 	;Full step angle_step 
		high c.3	low c.4 	low c.5 	;Half step angle_step
		;low c.3	high c.4	low c.5 	;1/4  step angle_step
		;high c.3	high c.4	low c.5 	;1/8  step angle_step
		;low c.3	low c.4 	high c.5	;1/16 step angle_step
		;high c.3	high c.4	high c.5	;1/32 step angle_step

 main:
 	readadc  0,sen1_val; read sensors an place in storage ,sen1_val;
 	readadc  1,sen2_val; read sensors an place in storage ,sen2_val;
	readadc  2,sen3_val; read sensors an place in storage ,sen3_val;
 	readadc  3,sen4_val; read sensors an place in storage ,sen4_val;
 	readadc  9,sen5_val; read sensors an plasce in storage ,sen5_val;
 	readadc  11,sen6_val;read sensors an plase in storage ,sen6_val;
 	readadc  10,sen7_val; read sensors an place in storage ,sen7_val;
 	readadc  13,sen8_val;read sensors an place in storage ,sen8_val;
 
 		 
 ;desision     ;sensor lev is low when over the white line
 	If  sen1_val < level then goto right
	If  sen2_val < level then goto right
	if  sen4_val < level and sen3_val < level then goto right
	If  sen4_val < level and sen5_val < level then goto nothing		
	If  sen5_val < level and sen6_val < level then goto left
	If  sen7_val < level then goto left
	If  sen8_val < level then goto left
	
	
goto main
 Left:
	  high  motor_dir
  goto stepmotor
 return
 
 Right:
 	low motor_dir
  goto stepmotor
 return

nothing:
goto main

Stepmotor:
	high motor	;high and low pin c.2 to form a pulstrain to stepper
	;pause 1
	low motor	;high and low pin c.2 to form a pulstrain to stepper 
	;pause 1
	
goto main
	
 endofcode:
I will start a new tread for the "auto camera pointing" Erco, I wil replly on your laser post in there.

Thank you all,

Willy
 
Top