Can the anyone help my?
I have gotten a readout on the value ”RPMCounter” with the command:
serout 7,T2400,(254,"Speed: ",#RPMCounter," rpm ",255)
Why 2 time "serout!
1: main_loop:goto main_loop
2: interrupt:return
The complete basic code is listed below.
I need to have the ”LKR-motor og interrupt DS1307 Clock” Basic codes for control of the motor
in the first picaxe-28X circuit, as it’s then possible for me to add further phases when needed.
And a second picaxe-28X circuit for parallel display HD44780 with ”hippy” higlighted Basic-codes
for display control.
But how do I transfer the value of the variable ” RPMCounter” to the second circuit since
it’s now supposed to show the RPM counter value?
The speed of the engine is now showing 600 rpm in the display.
I’m using 4Mhz crystal for PICAXE-28X.
Is it possible for me to use 8 or 16Mhz crystal to increase the speed?
I would like a rotating speed of about 2000 rpm.
My Code:
'Declare symbols
symbol RPMCounter = w4 ' b8 and b9
symbol IntMask = b13
'DS1307 SQW/OUT interface on pin 2 of the PICAXE 28X (leg 13)
symbol MASK_BIT = %00000100
'Save locations for interrupt handling
symbol SaveB10 = $50
symbol SaveB11 = $51
'Phase windings on PICAXE output pins
symbol R_Phase = 0
symbol S_Phase = 1
symbol T_Phase = 2
'#########################################################
' Start of code
'#########################################################
'Set up the DS1307 on the 12c bus
i2cslave %11010000, i2cslow, i2cbyte
pause 40
'Set 1307 to 00:00:00, Wednesday, 30 November, 05 and SQW/OUT to 1Hz
writei2c 0, ($00, $00, $00, $04, $30, $11, $05, $10)
'Do something (what?) to the LCD
serout 7,T2400,(254,1,255)
pause 30
serout 7,T2400,(254,128)
'Set the R phase high - first run only
high R_Phase
'Toggle the mask bit as we want the -ve edge of SQWE...
IntMask = IntMask ^ MASK_BIT
'...and inititialise the interrupt
setint IntMask, MASK_BIT
'#########################################################
' Main loop
' This loop runs continuously
' Every 1 second, caused by the 1307 interrupt, the RPM is
' displayed on the LCD
'#########################################################
main_loop:
serout 7,T2400,(254,"Speed: ",#RPMCounter," rpm ",255)
'Delay according to speed controller value
gosub speed_delay
'Rotate motor...
high R_Phase
high S_Phase
low T_Phase
'Delay according to speed controller value
gosub speed_delay
'Rotate motor...
low R_Phase
high S_Phase
high T_Phase
'Delay according to speed controller value
gosub speed_delay
'Rotate motor...
high R_Phase
low S_Phase
high T_Phase
'Increment the RPM counter
RPMCounter = RPMCounter + 1
goto main_loop
'#########################################################
' speed_delay
' Destroys b10, b11
'#########################################################
speed_delay:
'Initialise a temporary variable
b10 = 0
readadc 0,b11 'read A0
delay_loop:
b10 = b10 + 1
if b10 >= b11 then end_speed_delay
goto delay_loop
end_speed_delay:
return
'#########################################################
' Interrupt
'#########################################################
interrupt:
'save working variables in case of use in the interrupt routine
poke SaveB10, b10
poke SaveB11, b11
if IntMask = MASK_BIT then re_enable_interrupt
'This is the code that runs every 1 second...
'Show the RPM counter on the LCD display...
'...but convert to RPM first...
RPMCounter = RPMCounter * 60
sertxd("Value: ",#RPMCounter,13,10)
serout 7,T2400,(254,128,"Speed: ",#RPMCounter," rpm "
'...and then reset the counter for use in the next second
RPMCounter = 0
re_enable_interrupt:
'Toggle the mask bit...
IntMask = IntMask ^ MASK_BIT
'...and reset the interrupt
setint IntMask, MASK_BIT
'restore all saved variables
peek SaveB10, b10
peek SaveB11, b11
return
Best regards
Monie
I have gotten a readout on the value ”RPMCounter” with the command:
serout 7,T2400,(254,"Speed: ",#RPMCounter," rpm ",255)
Why 2 time "serout!
1: main_loop:goto main_loop
2: interrupt:return
The complete basic code is listed below.
I need to have the ”LKR-motor og interrupt DS1307 Clock” Basic codes for control of the motor
in the first picaxe-28X circuit, as it’s then possible for me to add further phases when needed.
And a second picaxe-28X circuit for parallel display HD44780 with ”hippy” higlighted Basic-codes
for display control.
But how do I transfer the value of the variable ” RPMCounter” to the second circuit since
it’s now supposed to show the RPM counter value?
The speed of the engine is now showing 600 rpm in the display.
I’m using 4Mhz crystal for PICAXE-28X.
Is it possible for me to use 8 or 16Mhz crystal to increase the speed?
I would like a rotating speed of about 2000 rpm.
My Code:
'Declare symbols
symbol RPMCounter = w4 ' b8 and b9
symbol IntMask = b13
'DS1307 SQW/OUT interface on pin 2 of the PICAXE 28X (leg 13)
symbol MASK_BIT = %00000100
'Save locations for interrupt handling
symbol SaveB10 = $50
symbol SaveB11 = $51
'Phase windings on PICAXE output pins
symbol R_Phase = 0
symbol S_Phase = 1
symbol T_Phase = 2
'#########################################################
' Start of code
'#########################################################
'Set up the DS1307 on the 12c bus
i2cslave %11010000, i2cslow, i2cbyte
pause 40
'Set 1307 to 00:00:00, Wednesday, 30 November, 05 and SQW/OUT to 1Hz
writei2c 0, ($00, $00, $00, $04, $30, $11, $05, $10)
'Do something (what?) to the LCD
serout 7,T2400,(254,1,255)
pause 30
serout 7,T2400,(254,128)
'Set the R phase high - first run only
high R_Phase
'Toggle the mask bit as we want the -ve edge of SQWE...
IntMask = IntMask ^ MASK_BIT
'...and inititialise the interrupt
setint IntMask, MASK_BIT
'#########################################################
' Main loop
' This loop runs continuously
' Every 1 second, caused by the 1307 interrupt, the RPM is
' displayed on the LCD
'#########################################################
main_loop:
serout 7,T2400,(254,"Speed: ",#RPMCounter," rpm ",255)
'Delay according to speed controller value
gosub speed_delay
'Rotate motor...
high R_Phase
high S_Phase
low T_Phase
'Delay according to speed controller value
gosub speed_delay
'Rotate motor...
low R_Phase
high S_Phase
high T_Phase
'Delay according to speed controller value
gosub speed_delay
'Rotate motor...
high R_Phase
low S_Phase
high T_Phase
'Increment the RPM counter
RPMCounter = RPMCounter + 1
goto main_loop
'#########################################################
' speed_delay
' Destroys b10, b11
'#########################################################
speed_delay:
'Initialise a temporary variable
b10 = 0
readadc 0,b11 'read A0
delay_loop:
b10 = b10 + 1
if b10 >= b11 then end_speed_delay
goto delay_loop
end_speed_delay:
return
'#########################################################
' Interrupt
'#########################################################
interrupt:
'save working variables in case of use in the interrupt routine
poke SaveB10, b10
poke SaveB11, b11
if IntMask = MASK_BIT then re_enable_interrupt
'This is the code that runs every 1 second...
'Show the RPM counter on the LCD display...
'...but convert to RPM first...
RPMCounter = RPMCounter * 60
sertxd("Value: ",#RPMCounter,13,10)
serout 7,T2400,(254,128,"Speed: ",#RPMCounter," rpm "
'...and then reset the counter for use in the next second
RPMCounter = 0
re_enable_interrupt:
'Toggle the mask bit...
IntMask = IntMask ^ MASK_BIT
'...and reset the interrupt
setint IntMask, MASK_BIT
'restore all saved variables
peek SaveB10, b10
peek SaveB11, b11
return
Best regards
Monie