PDA

View Full Version : variable modifiers / aliases...



comwarrior
- 9th October 2010, 23:01
ok, first off... i'm now the proud owner of PBP2.60a... u2 programmer is also on it's way...

i'm driving a stepper motor driver IC from a pic.
the driver IC has several inputs for it's settings...

For example, torque setting is two bits (4 settings), 25%(00), 50%(01) 75%(10) and 100% (11).
PBP doesn't support doing the following...


Torque var byte
torque.0 var PORTD.6
Torque.1 var PORTD.5

The torque setting is changed from the menu (to be writen) so it would be easier to just increase the variable by 1 up to 4 rarther than having to mess around with torque1 and torque2 separate vars.

is their a better way?
Thanks

aratti
- 9th October 2010, 23:15
I can suggest the following solution:



Torque Var Byte

Select Case Torque

Case Torque = 25
PortD.6 = 0: PortD.5 = 0

Case Torque = 50
PortD.6 = 0: PortD.5 = 1

Case Torque = 75
PortD.6 = 1: PortD.5 = 0

Case Torque = 100
PortD.6 = 1: PortD.5 = 1

End Select


Cheers

Al.

comwarrior
- 9th October 2010, 23:48
hmmm, never used select... I'll look it up in the manual for some bedtime reading... :cool:

Thanks for that aratti.

Edit: i looked in the manual, it doesn't specify if select case is used once or is 'ran' whenever you want to update?

aratti
- 10th October 2010, 09:29
Edit: i looked in the manual, it doesn't specify if select case is used once or is 'ran' whenever you want to update?

I suggest you to place the snippet in a subroutine and call it, with a GOSUB, all the times you need to change your torque setting.

Al.

comwarrior
- 10th October 2010, 13:15
Thats what i thought...

I think i'll put all three in an 'update' subroutine since at the moment it's only called twice, one at initialisation and once when you hit the 'go' button. however, a later revision may decide that you can change these settings while it's running...

thanks again aratti :)

kenif
- 14th October 2010, 16:43
If you really need soft then Arrati has it.

Personally, I would start a project like that with torque select jumpers on the board and save precious pins for the feature creep you know is coming.