Dear sirs, I have been using Great Cow Basic since 2 years ago and follow their progress, is a very usefull program. Thanks for that..
now I have a problem and I don't find it, can you help me?
The problem is:
Error: Variable PORTA is of type BYTE and does not have a bit 10
Error: Variable PORTA is of type BYTE and does not have a bit 11
#chip 16F628A, 4
#config CP_OFF, DATA_CP_OFF, PWRTE_OFF, WDT_OFF, LVP_OFF, MCLRE_OFF, _INTOSC_OSC_NOCLKOUT
dir PORTB b'00000000'
dir portb out
dir PORTA b'11111111'
dir porta in
#define etapa porta.0
#define direcc porta.1
#define enable porta.2
dir etapa in
dir direcc in
dir enable in
dim CM(8)
CM(1)=1:CM(2)=3:CM(3)=2:CM(4)=6:CM(5)=4:CM(6)=12:CM(7)=8:CM(8)=9
rt=1
seguir:
if enable=0 and etapa=0 then
if direcc=0 then
rt=rt+1
if rt=9 then rt=1
end if
if direcc=1 then
rt=rt-1
if rt=1 then rt=9
end if
portb=cm(rt)
wait 150 ms
end if
goto seguir
END
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Cannot follow that code at all. Much better to repair your previous code on the servo question, even tho we know its a stepper. If we incorporate the previous suggestions, and add a few more, your code may be ready. Always helps to understand what you are doing, and it looks like half stepping a bipolar stepper motor.
More suggestions:
1) Forget about setting the whole "dir PortA In", just use what you need. Like,
dir etapa in
dir direcc in
dir enable in
Trying to set the portA, and the seperate pins, probably gave you your errors. Not sure what etapa does, its not required to get the stepper going. Get the basics going first, before adding more features.
2) The previous code no doubt had undefined array error because "derecha(PL)
and izquierda(PL)". You are not trying to pass a variable to derecha or izquierda.
3) The delay in the main program could be crucial? You need some value that will give the stepper some compromise between speed and torque. The manufacturer of the stepper motor would give you a chart that represents this relationship in pps (pulses per second).
#chip 16F628A, 4
#config CP_OFF, DATA_CP_OFF, PWRTE_OFF, WDT_OFF, LVP_OFF, MCLRE_OFF, _INTOSC_OSC_NOCLKOUT
dir PORTB b'00000000' 'PORTB.3 as output
#define DIRECC porta.0
#define ENABLE porta.1
dir direcc in
dir enable in
dim CM(8)
CM(1)=1:CM(2)=3:CM(3)=2:CM(4)=6:CM(5)=4:CM(6)=12:CM(7)=8:CM(8)=9
seguir:
if DIRECC=0 and ENABLE=1 then derecha
if DIRECC=1 and ENABLE=1 then izquierda
wait 10 ms 'adjust delay as required
goto seguir
sub derecha 'hace step a la derecha
Pl=Pl+1
set portb = CM(PL)
if PL = 8 then PL = 1
return
sub izquierda 'hace step a la izquierda
PL=PL-1
set portb = CM(PL)
if PL = 1 then PL = 8
return
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dear sirs, I have been using Great Cow Basic since 2 years ago and follow their progress, is a very usefull program. Thanks for that..
now I have a problem and I don't find it, can you help me?
The problem is:
Error: Variable PORTA is of type BYTE and does not have a bit 10
Error: Variable PORTA is of type BYTE and does not have a bit 11
#chip 16F628A, 4
#config CP_OFF, DATA_CP_OFF, PWRTE_OFF, WDT_OFF, LVP_OFF, MCLRE_OFF, _INTOSC_OSC_NOCLKOUT
dir PORTB b'00000000'
dir portb out
dir PORTA b'11111111'
dir porta in
#define etapa porta.0
#define direcc porta.1
#define enable porta.2
dir etapa in
dir direcc in
dir enable in
dim CM(8)
CM(1)=1:CM(2)=3:CM(3)=2:CM(4)=6:CM(5)=4:CM(6)=12:CM(7)=8:CM(8)=9
rt=1
seguir:
if enable=0 and etapa=0 then
if direcc=0 then
rt=rt+1
if rt=9 then rt=1
end if
if direcc=1 then
rt=rt-1
if rt=1 then rt=9
end if
portb=cm(rt)
wait 150 ms
end if
goto seguir
END
Cannot follow that code at all. Much better to repair your previous code on the servo question, even tho we know its a stepper. If we incorporate the previous suggestions, and add a few more, your code may be ready. Always helps to understand what you are doing, and it looks like half stepping a bipolar stepper motor.
More suggestions:
1) Forget about setting the whole "dir PortA In", just use what you need. Like,
dir etapa in
dir direcc in
dir enable in
Trying to set the portA, and the seperate pins, probably gave you your errors. Not sure what etapa does, its not required to get the stepper going. Get the basics going first, before adding more features.
2) The previous code no doubt had undefined array error because "derecha(PL)
and izquierda(PL)". You are not trying to pass a variable to derecha or izquierda.
3) The delay in the main program could be crucial? You need some value that will give the stepper some compromise between speed and torque. The manufacturer of the stepper motor would give you a chart that represents this relationship in pps (pulses per second).
#chip 16F628A, 4
#config CP_OFF, DATA_CP_OFF, PWRTE_OFF, WDT_OFF, LVP_OFF, MCLRE_OFF, _INTOSC_OSC_NOCLKOUT
dir PORTB b'00000000' 'PORTB.3 as output
#define DIRECC porta.0
#define ENABLE porta.1
dir direcc in
dir enable in
dim CM(8)
CM(1)=1:CM(2)=3:CM(3)=2:CM(4)=6:CM(5)=4:CM(6)=12:CM(7)=8:CM(8)=9
seguir:
if DIRECC=0 and ENABLE=1 then derecha
if DIRECC=1 and ENABLE=1 then izquierda
wait 10 ms 'adjust delay as required
goto seguir
sub derecha 'hace step a la derecha
Pl=Pl+1
set portb = CM(PL)
if PL = 8 then PL = 1
return
sub izquierda 'hace step a la izquierda
PL=PL-1
set portb = CM(PL)
if PL = 1 then PL = 8
return