'{$STAMP BS1} ' *********************************************************************** ' * * ' * Source code for Basic Stamp 1 microcontrollers * ' * used for pwm controll of softshift solenoids on bows * ' * by Dr.Godfried-Willem Raes * ' * Filename: FLEX_PWM.BS1 * ' *********************************************************************** ' 29.10.1995: Note: ' BSLOAD must run under DOS, not in a dos Window under WFWIN!!! ' 26.01.2003: Code written. We need 4 BS1's ' 27.01.2003: PC board takes 4 16C56 PICS. We do not use the SMD stamp, but ' build it from discrete components. ' They accept 1 nibble data input through their pins 0-3, and output pwm-signals ' from their pin 7's. Resolution is <= 4 bits. ' Pin 7 may be connected to an RC-circuit, for integration: ' 4.7kOhm- 0.47mF gives 2.2 ms RC time Icmax=1mA ' 10kOhm - 470nF Used in , 1995 ' 10kOhm - 1 mF gives 10ms RC-time ' 10kOhm - 10mF gives an 0.1s RC-time Icmax=0.5mA ' 100kOhm - 1 mF gives the same result. Icmax=50microamps ' The dc-signal should be buffered. The DC range is 0-5V ' CODE-LIST: ' timing ' comments ' ' 0.5ms/instruction Init: dirs = %10000000 ' same as: ' input 0 ' 1ms ' input pin data bit 0 ' input 1 ' ' input pin data bit 1 ' input 2 ' ' input pin data bit 2 ' input 3 ' ' input pin data bit 3 ' input 4 ' ' nc ' input 5 ' 1ms ' nc ' input 6 ' 1ms ' nc ' output 7 ' 1ms ' pwm output pin , for drift reduction we could also make it input. input 7 Begin: b2 = pins b2 = b2 & %00001111 ' isolate low nibble if b2 = 0 then SolOff if b2 = 15 then SolMax b2 = b2 + 1 * 16 - 1 ' add 1 and rotate left 4 bits , so now we have 2 - 256 pwm 7,b2, 10 ' send out 1 - 255, do PWM for 10 periods. goto Begin SolOff: 'output 7 low 7 'out7, 0 goto Begin SolMax: 'output 7 high 7 'out7, 1 goto Begin bsave ' creates an OBJ file to disk