PROPASM help HAll sensor
Rob v.d. berg
Posts: 89
Hi,
In·an application i use·Hall sensor A3422 (Allegro), they·have two output signals,·speed·and·direction.
The speed is an puls (negative), and the direction is a level.·The sensor gives the position back of a piston.
Here·is a·simple spin program to make it work,·for low speed / rpm's.
Will someone help me to convert this in propeller assembly·language, to make it also suitable for higher·speed,·separat·COG?.
(There is no existing·object exchange source, all encoders·uses·A and B signals)
regards
Rob.
(There is no existing·object exchange source, all encoders·uses·A and B signals)
'········ ______ ok L · ·_______ ok R··______not ok· _____
'Speed··· ····· |_____|········ ···|_____|········· |_____|
'················· V··· ·· ·V········· ·V······· V··········V······· V
'········ ____············· ······ · ____________········· ______
'Dir··········· |____________|················ ·· |_____|
*********************************************
· dira[noparse][[/noparse]Speed]~·············· 'input
· dira[noparse][[/noparse]Dir]~··················· 'input
· dira[noparse][[/noparse]Cyclus]~~············ 'output
repeat
··· Newstate := ina[noparse][[/noparse]Speed]································'get speed signal
··· if (not Newstate and OldState) and not start··· 'there is a high to low transition
······· start := true···········································'flag begin of puls
······· DirState := ina[noparse][[/noparse]Dir]···································'save level Direction signal
··· if (Newstate and not OldState) and start··········'there is a low to high transition, end of puls
······· start := false···········································'reset flag
······· if Dirstate == ina[noparse][[/noparse]Dir]·································'check level Direction,·begin and·end puls·equal?
··········· if Dirstate············································'if equal than puls is accepted.·
··············· Count--········································· 'depending of·low/high·direction count up/down
············else
··············· Count++
···
··· Oldstate := Newstate····································'save old speed signal
***********************************************************
In·an application i use·Hall sensor A3422 (Allegro), they·have two output signals,·speed·and·direction.
The speed is an puls (negative), and the direction is a level.·The sensor gives the position back of a piston.
Here·is a·simple spin program to make it work,·for low speed / rpm's.
Will someone help me to convert this in propeller assembly·language, to make it also suitable for higher·speed,·separat·COG?.
(There is no existing·object exchange source, all encoders·uses·A and B signals)
regards
Rob.
(There is no existing·object exchange source, all encoders·uses·A and B signals)
'········ ______ ok L · ·_______ ok R··______not ok· _____
'Speed··· ····· |_____|········ ···|_____|········· |_____|
'················· V··· ·· ·V········· ·V······· V··········V······· V
'········ ____············· ······ · ____________········· ______
'Dir··········· |____________|················ ·· |_____|
*********************************************
· dira[noparse][[/noparse]Speed]~·············· 'input
· dira[noparse][[/noparse]Dir]~··················· 'input
· dira[noparse][[/noparse]Cyclus]~~············ 'output
repeat
··· Newstate := ina[noparse][[/noparse]Speed]································'get speed signal
··· if (not Newstate and OldState) and not start··· 'there is a high to low transition
······· start := true···········································'flag begin of puls
······· DirState := ina[noparse][[/noparse]Dir]···································'save level Direction signal
··· if (Newstate and not OldState) and start··········'there is a low to high transition, end of puls
······· start := false···········································'reset flag
······· if Dirstate == ina[noparse][[/noparse]Dir]·································'check level Direction,·begin and·end puls·equal?
··········· if Dirstate············································'if equal than puls is accepted.·
··············· Count--········································· 'depending of·low/high·direction count up/down
············else
··············· Count++
···
··· Oldstate := Newstate····································'save old speed signal
***********************************************************
Comments
Although this code conversion to ASM is very doable and should be pretty simple, I would highly recommend checking out Bean's PropBasic as it should give you the ease of high level programming and the speed that only ASM can offer. I think the time you spend learning the basic syntax would be well spent not only to complete your current project but also for future ones also. To download PropBasic just look in this forum for Beans almost daily revisions being posted, its in there as an attachment.
thanks,·i saw it, looks good.·But it is again an other IDE/compiler. The last 2 years i'm busy with converting hardware / software into the prop. So started with java stamp / and some SX /·now prop.·The last converting part is a SX motorcontrol part.
so i need: PWM (10K, 255 steps) / uart input / Hall sensor a3422 input. The PWM and Hall sensor are in asm.
Is it possible in PropBasic to make a high level part,·than inport the asm code in SPIN/IDE?
regards,
Rob.