'************************************************************************* '* <4 Phase stepping motor controller> * '* by * '* Dr.Godfried-Willem RAES * '* Stamp2 Hardware version 1.3 * '* Filename : * '* Code version 1.4 * '************************************************************************* '{$STAMP BS2p} 'STAMP directive (specifies a BS2P) ' 20.09.2001: First version ' The highest frequency is obtained by pulling all bits 0-7 high. ' Stepping motor specs: 7.5 deg/step, 36 Ohms coil resistance ' Type: 55SI-25DAWC, made in Japan 21.dec.1983TD ' We use two steppers, one for each rotary bar. ' 23.09.2001: pincode trick added on start up. ' 01.10.2001: Hardware tests and measuments... ' slowest speed is ca. 1.2 Hz ' 05.10.2001: scaling changed. Now turns slower and code cannot exceed possibilities of stepper used. ' 14.02.2005: update vibi. ' 26.06.2005: failure of vibi... revision. ' motor 0 (diatonic) runs o.k., motor 1 (same code) stutters at high speeds. ' File version Vibistepper4.bs2 not tested yet. Should perform better! ' Much more responsive to continuous controllers. ' DECLARATIONS: Centrobyte VAR Byte ' incoming byte, from Vibi-pp board 'glitchbyte VAR Byte ' 26.06.2005 - input deglitcher Period VAR Word Pincode VAR Byte ' INITIALISATION: ' parallel input bits 0 to 7 ' these bits are mapped on a midi controller ' make this byte an input: DIRL = 0 ' pins 10,11 get pulsed (alternating) and let the user display the frequency generated, ' pin 8 used as steering bit to switch on the 48V power supply for the solenoids ' after reception of the correct pincode on the datainput bus. ' pin 9 is not used. DIRC = $F 'DIR12 = 1 :' phase 1 output 'DIR13 = 1 :' phase 2 output 'DIR14 = 1 :' phase 3 output 'DIR15 = 1 :' phase 4 output ' these pins steer the gates of 4 logic level 4 Amps power mosfets. DIRD = $F OUTD = 0 'LOW 8 ' keybit 'LOW 12 ' steppers 'LOW 13 'LOW 14 'LOW 15 ' Initialisation of variables: Pincode = 251 ' largest 8 bit prime number 'Status = 0 ' 0 means motor stopped ' 1 means motor running ' Initialisation code:*************************************************** ' here we wait for reception of PINCODE, before we start. ' Reception of PINCODE will switch 48V power supply on ' for solenoids. ' DEBUG "Vibi stepping motor controller V1.3" Init: Centrobyte = INL IF Centrobyte <> PINCODE THEN Init ' DEBUG DEC Pincode HIGH 8 ' should switch on 48V power supply ' this pin should have a pull down resistor! ' now we should avoid that the motors start running with the value of the pincode... OUTD = 0 SkipPincode: Centrobyte = INL IF Centrobyte = Pincode THEN SkipPinCode ' START OF RUN-CODE:***************************************************** Begin: ' Glitchbyte = INL Centrobyte = INL ' IF Glitchbyte <> Centrobyte THEN Begin ' deglitch procedure IF Centrobyte = 0 THEN SetOff Period = 256 - Centrobyte '1 -255 'timing adjusted for BS2p24 'voor deBS2p is de resolutie 1.18 microsekonde per unit en nemen we beter: Period = Period << 6 ' = * 64 64 - 16320 of, 75microsec. tot 19.2ms 'start van 1e sekwens van vier stappen OUTD = 8 '1000 PULSOUT 11, Period Centrobyte = INL IF Centrobyte = 0 THEN SetOff Period = 256 - Centrobyte Period = Period << 6 OUTD = 12 '1100 PULSOUT 10, Period Centrobyte = INL IF Centrobyte = 0 THEN SetOff Period = 256 - Centrobyte Period = Period << 6 OUTD = 4 '0100 PULSOUT 11, Period Centrobyte = INL IF Centrobyte = 0 THEN SetOff Period = 256 - Centrobyte Period = Period << 6 OUTD = 6 '0110 PULSOUT 10, Period Centrobyte = INL IF Centrobyte = 0 THEN SetOff Period = 256 - Centrobyte Period = Period << 6 OUTD = 2 '0010 PULSOUT 11, Period Centrobyte = INL IF Centrobyte = 0 THEN SetOff Period = 256 - Centrobyte Period = Period << 6 OUTD = 3 '0011 PULSOUT 10, Period Centrobyte = INL IF Centrobyte = 0 THEN SetOff Period = 256 - Centrobyte Period = Period << 6 OUTD = 1 '0001 PULSOUT 11, Period Centrobyte = INL IF Centrobyte = 0 THEN SetOff Period = 256 - Centrobyte Period = Period << 6 OUTD = 9 '1001 ' einde 1e sekwens van vier stappen PULSOUT 12, Period GOTO Begin SetOff: OUTD = 0 ' = LOW 12, LOW 13, LOW 14, LOW 15 GOTO Begin END