Balderbraa
Member
Greetings!
Just wandering if I`m on the right track here.
The general idea is to bombard a 08M2 hserin with two bytes containing address for the device and the speed and then let the 08M2 adjust the pwm-frequensy and direction pins(this will be used to drive a currently unknown H-Bridge)
I wrote this snippet of code for the 18M2 and it simulates fine but I`m not sure if i understand the 2byte fifo buffer well enough.
If i send device address first and then the speed many times a second will they fall into the same fifo space every time or does it depend on where you currently are in the code? When does the new byte replace the old one?
Any help is welcome.
Regards
Just wandering if I`m on the right track here.
The general idea is to bombard a 08M2 hserin with two bytes containing address for the device and the speed and then let the 08M2 adjust the pwm-frequensy and direction pins(this will be used to drive a currently unknown H-Bridge)
I wrote this snippet of code for the 18M2 and it simulates fine but I`m not sure if i understand the 2byte fifo buffer well enough.
Code:
Symbol Address=b0
Symbol Speed=b1
Symbol duty=b2
Symbol Device_adress=3
setfreq m32
hsersetup b115200_32,%00001000
Main:
Hserin Address
Hserin Speed
If address<>Device_Adress then goto main
If speed=128 then goto main
If speed<128 then goto Backward_
Goto forward_
Forward_:
Low c.0
High b.4 ;Should be c.4 for 08m2
Speed=Speed-128
Duty=speed*3
Pwmout pwmdiv4,B.3,99,Duty ;Should be c.2 for 08m2
Goto main
Backward_:
High c.0
low b.4 ;Should be c.4 for 08m2
Speed=128-speed
Duty=speed*3
Pwmout pwmdiv4,B.3,99,Duty ;Should be c.2 for 08m2
Goto main
Any help is welcome.
Regards