First Post, and new to PIC''s, Please be gentle
Archiver
Posts: 46,084
Hello All,
I am new, so please understand that. I have this idea to use the
pic to control some Stepper motors. After some research, I found a
product called the BiStep, which can be seen here
http://www.stepperboard.com/ . Basically, the BiStep recieves serial
data, and controls the steppers, making it very easy, at least for me.
I just have a couple of questions about the PIC, and PIC Basic I am
hoping someone can answer for me.
First, when writing comments, can I use quotes around some text,
or will that confue the PIC.
Second, the BiStep outputs a TTL level HI signal when a motor is
active. I want to be able to monitor this signal. Can I just
connect it to a pin on the PIC that has been set as an INPUT, or do I
need to worry about voltages and signal levels and the like? Also, I
want to connect this to a car. I would like to PIC to sense for
ignition. Can I just use an accessory wire from the fuse box
straight into the PIC, or do something like a relay, which connects
another input pin on the pic to either the pics ground, or 5 volts
supply?
Next, I have some code (Don't worry, it will follow), but I would
like to know if there is a free program on line that I can download,
and run the PicBasic program in, to wee if it works, and what happens.
And last, here is the code. PLEASE BE GENTLE. It was my absolute
first time programing in anything since high school, and back then,
it was all in BASIC. That is how long ago that was. I use alot of
gosubs, only because to me, the actions of the motors basically goes
like this
Wait for the switch to turn on
Set the "in" location on motor 1
send motor 1 to the "out" location
wait for the motors to stop
set the "in" location on motor 2
send motor 2 to the "out" location
wait for the motor to stop
wait for the swicth to turn off
set motor 2 current location as the "out" location
send motor 2 to the in location
wait for the motor to stop turning
set motor 1 current location to the out position
send motor 1 to the in location
wait for the motor to stop turning
end program
Here is the code
`This progam will control a BiStep Stepper motor controller. It
is 'being used to create a movable LCD screen for a `carputer. The
BiStep `is controled serially with some simple text. The only
feedback `between the BiStep and the pic is a `ttl level, HI
when "busy" signal. `The BiStep does output serial communication if
needed, but I have no `use for it, so it `is not implemented. When
the BiStep and is powered, `and the PIC senses that the car key is in
at least the accessory `position, the PIC send a serial command to
move the motor till the `open poition. Once the "busy line" goes
LOW, the PIC `tell the BiStep `to move the second motor out. Then,
when the key is turned off, the `second motor returns to the in
`position, and when the busy line goes `LOW again, the first motor
goes to the in position.
Symbol Motorrunning = pin3 `Assign pin3 an easy name to use
Symbol Ignsense = pin4 `Assign pin4 an easy name
input 3
pause 2000 `pause for 2 seconds, waiting for BiStep to initialize
gosub motoroneout
gosub waitformotor
gosub motortwoout
gosub waitformotor
gosub sense
gosub motortwoin
gosub waitformotor
gosub motoronein
gosub waitformotor
end
motoroneout:
serout 1,N9600, ("y=1") `send y=1 serially to the BiStep,
serout 1,n9600, ("1m") `send 1m serially,
return
waitformotor:
if motorrunning = o then pause `If motor turning, then pause
return
pause:
pause 500 `pause for half a second
return
motortwoout:
serout 1,n9600, ("x=1") `send x=1 serially to the BiStep
serout 1,n9600, ("1m") `send 1m serially
return
Sense:
if ignsense = 1 then goto sense `Checking ignition switch
return
motortwoin:
serout 1,n9600, ("y") `send y serially
serout 1,n9600, ("0m") `send 0m serially
serout 1,n9600, ("0g") `send OG serially
return
motoronein:
serout 1,n9600, ("x") `send X serially, chooses X motor
serout 1,n9600, ("0m") `send 0m serially
serout 1,n9600, ("0g") send OG serially
return
I am new, so please understand that. I have this idea to use the
pic to control some Stepper motors. After some research, I found a
product called the BiStep, which can be seen here
http://www.stepperboard.com/ . Basically, the BiStep recieves serial
data, and controls the steppers, making it very easy, at least for me.
I just have a couple of questions about the PIC, and PIC Basic I am
hoping someone can answer for me.
First, when writing comments, can I use quotes around some text,
or will that confue the PIC.
Second, the BiStep outputs a TTL level HI signal when a motor is
active. I want to be able to monitor this signal. Can I just
connect it to a pin on the PIC that has been set as an INPUT, or do I
need to worry about voltages and signal levels and the like? Also, I
want to connect this to a car. I would like to PIC to sense for
ignition. Can I just use an accessory wire from the fuse box
straight into the PIC, or do something like a relay, which connects
another input pin on the pic to either the pics ground, or 5 volts
supply?
Next, I have some code (Don't worry, it will follow), but I would
like to know if there is a free program on line that I can download,
and run the PicBasic program in, to wee if it works, and what happens.
And last, here is the code. PLEASE BE GENTLE. It was my absolute
first time programing in anything since high school, and back then,
it was all in BASIC. That is how long ago that was. I use alot of
gosubs, only because to me, the actions of the motors basically goes
like this
Wait for the switch to turn on
Set the "in" location on motor 1
send motor 1 to the "out" location
wait for the motors to stop
set the "in" location on motor 2
send motor 2 to the "out" location
wait for the motor to stop
wait for the swicth to turn off
set motor 2 current location as the "out" location
send motor 2 to the in location
wait for the motor to stop turning
set motor 1 current location to the out position
send motor 1 to the in location
wait for the motor to stop turning
end program
Here is the code
`This progam will control a BiStep Stepper motor controller. It
is 'being used to create a movable LCD screen for a `carputer. The
BiStep `is controled serially with some simple text. The only
feedback `between the BiStep and the pic is a `ttl level, HI
when "busy" signal. `The BiStep does output serial communication if
needed, but I have no `use for it, so it `is not implemented. When
the BiStep and is powered, `and the PIC senses that the car key is in
at least the accessory `position, the PIC send a serial command to
move the motor till the `open poition. Once the "busy line" goes
LOW, the PIC `tell the BiStep `to move the second motor out. Then,
when the key is turned off, the `second motor returns to the in
`position, and when the busy line goes `LOW again, the first motor
goes to the in position.
Symbol Motorrunning = pin3 `Assign pin3 an easy name to use
Symbol Ignsense = pin4 `Assign pin4 an easy name
input 3
pause 2000 `pause for 2 seconds, waiting for BiStep to initialize
gosub motoroneout
gosub waitformotor
gosub motortwoout
gosub waitformotor
gosub sense
gosub motortwoin
gosub waitformotor
gosub motoronein
gosub waitformotor
end
motoroneout:
serout 1,N9600, ("y=1") `send y=1 serially to the BiStep,
serout 1,n9600, ("1m") `send 1m serially,
return
waitformotor:
if motorrunning = o then pause `If motor turning, then pause
return
pause:
pause 500 `pause for half a second
return
motortwoout:
serout 1,n9600, ("x=1") `send x=1 serially to the BiStep
serout 1,n9600, ("1m") `send 1m serially
return
Sense:
if ignsense = 1 then goto sense `Checking ignition switch
return
motortwoin:
serout 1,n9600, ("y") `send y serially
serout 1,n9600, ("0m") `send 0m serially
serout 1,n9600, ("0g") `send OG serially
return
motoronein:
serout 1,n9600, ("x") `send X serially, chooses X motor
serout 1,n9600, ("0m") `send 0m serially
serout 1,n9600, ("0g") send OG serially
return