Posted: 09:38pm 24 Nov 2012 |
Copy link to clipboard |
Print this post |
|
Ausome..!!! All is now working correctly..
I have the first MM connected to 6 MAX31855 temp IC's and creating a VGA "Bar-Guage" style readout with color temp ranges controled bay a simple setup program. The first MM also sends out the IC's data to the second MM connected to a small stepper motor based guage needle driver. This can be used as a remote guage readout mounted elsware (sweet) ..!
Guage driver code - (sofar)
For N=17 To 20: Pin(N)=0: SetPin N,8: Next N ' setup pins as output LOW
N=0: S=0: coilstate=1: Open "com1:9600, 1024" As #1
Print @(300,200) S
Print @(300,220) coilstate
Print "homeing.."
N = 655: GoSub moveguage
N = 0: GoSub moveguage
Do
' If N = S Then Input "New position "; N
If N = S Then GoSub Getvalue
Print N;
GoSub moveguage
Loop
moveguage:
While S <> N
Print @(300,200) " "
Print @(300,200) S
Print @(300,220) " "
Print @(300,220) coilstate
Pin(0)=1
If S <> N Then
If S > N Then coilstate = coilstate + 1
If S < N Then coilstate = coilstate - 1
If coilstate <= 0 Then coilstate = 4
If coilstate >= 5 Then coilstate = 1
On coilstate GoTo state1, state2, state3, state4
GoTo stepdone
state1:
Pin(20)=1: Pin(19)=1: Pin(18)=0: Pin(17)=0: GoTo stepdone
state2:
Pin(20)=0: Pin(19)=0: Pin(18)=1: Pin(17)=1: GoTo stepdone
state3:
Pin(20)=1: Pin(19)=0: Pin(18)=0: Pin(17)=0: GoTo stepdone
state4:
Pin(20)=0: Pin(19)=0: Pin(18)=1: Pin(17)=0
stepdone:
If S > N Then S = S-1
If S < N Then S = S+1
If S = N Then Pin(20)=0: Pin(18)=0
EndIf
Pin(0)=0
Wend
Return
Getvalue:
While rxbyte$ <> "#"
GoSub getbyte
Wend
Print "#"
GoSub getbyte
If rxbyte$ <> "E" Then GoTo getvalue
Print "E";
GoSub getbyte
If rxbyte$ <> "1" Then GoTo getvalue
Print "1";
GoSub getbyte
If rxbyte$ <> " " Then GoTo getvalue
Print " ";
GoSub getbyte
If rxbyte$ = Chr$(13) Or rxbyte$ = Chr$(10) Then GoTo getdone
If rxbyte$ >= "0" And rxbyte$ <= "9" Then N$ = rxbyte$
GoSub getbyte
If rxbyte$ = Chr$(13) Or rxbyte$ = Chr$(10) Then GoTo getdone
If rxbyte$ >= "0" And rxbyte$ <= "9" Then N$ = N$ + rxbyte$
GoSub getbyte
If rxbyte$ = Chr$(13) Or rxbyte$ = Chr$(10) Then GoTo getdone
If rxbyte$ >= "0" And rxbyte$ <= "9" Then N$ = N$ + rxbyte$
GoSub getbyte
If rxbyte$ = Chr$(13) Or rxbyte$ = Chr$(10) Then GoTo getdone
If rxbyte$ >= "0" And rxbyte$ <= "9" Then N$ = N$ + rxbyte$
getdone:
N = Val(n$)
Return
getbyte:
buffbytes = 0
While buffbytes = 0
buffbytes = Loc(#1)
Wend
rxbyte$ = Input$(1, #1)
Return
I used two DS3695 IC's as coil drivers. pin 20 is enable for coil one, with pin 19 being the coil direction of current flow. Same for coil two using pins 18 & 17...
now that it seems to be working, I wonder if the coils can be driven directly from the MM's I/O pins.. The coil current is very low but the 3.3v drive might not be enough... Will let ya know...
Still kinda hackie, but works... I need to study-up on more basic programming.!!
Thanks for all the help everyone..!
Edited by Zonker 2012-11-26 |