by i-Bot » Fri Jun 19, 2009 4:15 am
by i-Bot
Fri Jun 19, 2009 4:15 am
Sorry for the delay, I got a bit jet lagged coming home. I guess it being 4AM now means it aint quite fixed yet !
Any way, I rechecked the configuration and tested it here.
Are you still having problems ?, I am hoping it is a wiring mistake.
To recap, the dual colour LED is in common cathode (ground) configuration, so we run the common lead of the LEDs to ground (outside pins on board). The anodes of the red and green run through resistors to the PWM pins on the board(use pins nearest centre of board. The +5V of the PWM port (centre pin) is not used. The resistor should be of a value to limit the current from the pin to less than the maximum of 20mA. You may need different values for the red and green LED due to their different voltage drop and efficiency
The following RoboBasic code should turn the LED alternatively on and off. Ports are 46 and 47 decimal.
- Code: Select all
' Test LED on PWM pins
lable:
OUT 46,0
OUT 47,1
DELAY 1000
OUT 46, 1
OUT 47, 0
DELAY 1000
GOTO lable
The following code uses the PWM to change the intensity.
- Code: Select all
' Test for using FPWM to control LED on PWM ports
lable:
DIM i AS BYTE
DIM j AS BYTE
FOR i= 0 TO 255
j = 256 -i
FPWM 0,1,i
FPWM 1,1,j
DELAY 5
NEXT i
FOR i= 0 TO 255
j = 256 -i
FPWM 0,1,j
FPWM 1,1,i
DELAY 5
NEXT i
GOTO lable
When we run Gorts Laser sight (Trossen/Sparkfun) , this has its own power supply and a logic controlled switch. For this we power the laser from the battery rail to conserve power on the 5V rail. The ttl control goes to the PWM pin nearest the centre of the board. Ground for the laser module can come from any outside ground pin. The transistor switch does invert the output, OUT, 46,0 will be on and OUT 46,1 will be off.
For the pellet gun some external circuit will be needed. First since the gun is motor based, we need a diode across it to protect the circuit. Since the gun is best at battery voltage, the + end of the motor should go the the battery rail. The negative end should connect through an NPN transistor or N channel FET to ground. The base of this transistor should connect to the PWM pin through a resistor. You may also need a resistor to ground to prevent the gun from running before you are ready. Again the control will be inverted. Let me know if you want me to make a schemaitic and test it. would love a gun to do this, but can try with any motor.
Post some video when it working.
Sorry for the delay, I got a bit jet lagged coming home. I guess it being 4AM now means it aint quite fixed yet !
Any way, I rechecked the configuration and tested it here.
Are you still having problems ?, I am hoping it is a wiring mistake.
To recap, the dual colour LED is in common cathode (ground) configuration, so we run the common lead of the LEDs to ground (outside pins on board). The anodes of the red and green run through resistors to the PWM pins on the board(use pins nearest centre of board. The +5V of the PWM port (centre pin) is not used. The resistor should be of a value to limit the current from the pin to less than the maximum of 20mA. You may need different values for the red and green LED due to their different voltage drop and efficiency
The following RoboBasic code should turn the LED alternatively on and off. Ports are 46 and 47 decimal.
- Code: Select all
' Test LED on PWM pins
lable:
OUT 46,0
OUT 47,1
DELAY 1000
OUT 46, 1
OUT 47, 0
DELAY 1000
GOTO lable
The following code uses the PWM to change the intensity.
- Code: Select all
' Test for using FPWM to control LED on PWM ports
lable:
DIM i AS BYTE
DIM j AS BYTE
FOR i= 0 TO 255
j = 256 -i
FPWM 0,1,i
FPWM 1,1,j
DELAY 5
NEXT i
FOR i= 0 TO 255
j = 256 -i
FPWM 0,1,j
FPWM 1,1,i
DELAY 5
NEXT i
GOTO lable
When we run Gorts Laser sight (Trossen/Sparkfun) , this has its own power supply and a logic controlled switch. For this we power the laser from the battery rail to conserve power on the 5V rail. The ttl control goes to the PWM pin nearest the centre of the board. Ground for the laser module can come from any outside ground pin. The transistor switch does invert the output, OUT, 46,0 will be on and OUT 46,1 will be off.
For the pellet gun some external circuit will be needed. First since the gun is motor based, we need a diode across it to protect the circuit. Since the gun is best at battery voltage, the + end of the motor should go the the battery rail. The negative end should connect through an NPN transistor or N channel FET to ground. The base of this transistor should connect to the PWM pin through a resistor. You may also need a resistor to ground to prevent the gun from running before you are ready. Again the control will be inverted. Let me know if you want me to make a schemaitic and test it. would love a gun to do this, but can try with any motor.
Post some video when it working.