This
time I would like to present you how I have added a light around the extruder.
Instead of re-inventing the wheel I just bought a simple tent light in Argos (LINK).
Instead of re-inventing the wheel I just bought a simple tent light in Argos (LINK).
It
contains 2 rings with white 5mm LEDs and it is battery powered. It
takes 3x AA batteries so the maximum voltage is about 4.5V – close enough to
onboard 5V. I’m going to drive it using PWM so I’m not worried about exceeding
the limits (I’m sure there is a voltage margin in the product design so it will
not catch the flames if 4.51V is provided :)
I’ve created a circular holder for the rings:
I’ve created a circular holder for the rings:
To
mount the PCB rings – I simply marked all the holes in the PCBs with a tip of
soldering iron (mmmmm, that sweet smell of melted PLA :))
and then used some small screws lying around to hold the 2 rings in place.
Then
was a time to make some brackets to hold the lights next to the extruder:
To
mount it to the Z carriage arm I used clips from my previous design:
http://ljwinkler.blogspot.com/2014/01/frame-clip-and-locking-pin-for-velleman.html
http://ljwinkler.blogspot.com/2014/01/frame-clip-and-locking-pin-for-velleman.html
For the
PWM driver I used Atmega328P microcontroller with an Arduino bootloader. It is a
bit overkill using a microcontroller for such a simple purpose but it leaves me
an open window for future modifications and it was also very quick to set up from
parts I had. The other big advantage of this solution comes when a small tweaks
are required – it just means changing the source code and re-uploading it back
to the microcontroller.
I used one of the analogue inputs (A0 - pin 23) to read value of the potentiometer and one of the PWM outputs (D10 - pin 16) to drive a transistor that controls the LEDs. Atmega328P has a 10 bit A/D converter, therefore it can read 1024 positions of the potentiometer (0-1023). However, the PWM output is only 8-bit (0-255). I have modified the range to be 3-255 – so turning the potentiometer to its edge will turn off the lights completely. I have also added averaging of last 10 readings to prevent flickering.
A 4-pin header (Reset, RxD, TxD, GND) was added for programming purposes.
As a power supply I used the main controller board, pins marked as +5V and GND from the header J1 located in the corner of the controller board.
I used one of the analogue inputs (A0 - pin 23) to read value of the potentiometer and one of the PWM outputs (D10 - pin 16) to drive a transistor that controls the LEDs. Atmega328P has a 10 bit A/D converter, therefore it can read 1024 positions of the potentiometer (0-1023). However, the PWM output is only 8-bit (0-255). I have modified the range to be 3-255 – so turning the potentiometer to its edge will turn off the lights completely. I have also added averaging of last 10 readings to prevent flickering.
A 4-pin header (Reset, RxD, TxD, GND) was added for programming purposes.
As a power supply I used the main controller board, pins marked as +5V and GND from the header J1 located in the corner of the controller board.
Here is
a quick schematic:
List of
components used:
- 1x ATmega328P with Arduino bootloader
- 1x BUF644 NPN transistor
- 1x 16MHz crystal
- 2x 22p ceramic capacitor
- 1x 10k resistor
- 1x 100R resistor
- 1x 10k potentiometer
I have
soldered it on a single layer protoboard:
Then I
have designed a base for the PCB.
I have
created small support elements keeping the board raised 5 mm and holding it in place by two M3 screws
in the corners. The whole unit is mounted on the main controller board mount (described
here: http://ljwinkler.blogspot.ie/2014/01/controller-board-mount-for-velleman.html)
Afterwards I have
created a holder for the potentiometer. I have redesigned one of my clips -
this time I used the flat one as there are wires running underneath.
And here
is the source code:
// Arduino program
for PWM LED lighting
// Copyright 2014 -
LJ Winkler (lwinkler247@gmail.com)
//
//-------------------------------------------------------------------------//
// Permission is
hereby granted, free of charge, to any person //
// obtaining a copy
of this software and associated documentation files //
// (the
"Software"), to deal in the Software without restriction, //
// including
without limitation the rights to use, copy, modify, merge, //
// publish,
distribute, sublicense, and/or sell copies of the Software, //
// and to permit
persons to whom the Software is furnished to do so, //
// subject to the
following conditions: //
//
//
// The above
copyright notice and this permission notice shall be //
// included in all
copies or substantial portions of the Software. //
//
//
// THE SOFTWARE IS
PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, //
// EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF //
// MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. //
// IN NO EVENT
SHALL THE AUTHOR OR COPYRIGHT HOLDERS BE LIABLE FOR ANY //
// CLAIM, DAMAGES
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, //
// TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE //
// SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE. //
//-------------------------------------------------------------------------//
/*
* pin A0 - PWM pot input
* pin 10 - PWM output
*/
const int
numReadings = 10;
const int potINpin
= A0;
const int pwmOUTpin
= 10;
int potValue = 0;
int pwmValue = 0;
int
readings[numReadings];
int index = 0;
int total = 0;
int average = 0;
void setup() {
pinMode(pwmOUTpin, OUTPUT);
pinMode(potINpin, INPUT);
for (int thisReading = 0; thisReading <
numReadings; thisReading++){
readings[thisReading] = 0;
}
}
void loop() {
total = total - readings[index];
readings[index] = analogRead(potINpin);
total = total + readings[index];
index = index + 1;
if (index >= numReadings){
index = 0;
}
average = total / numReadings;
pwmValue = map(average, 0, 1023, 255,
0);
if(pwmValue<3){
pwmValue=0;
}
analogWrite(pwmOUTpin, pwmValue);
delay(1);
}
To
download the files - visit my profile on Thingiverse (http://www.thingiverse.com/ljwinkler/designs) or use direct links below:
- LED rings mount (http://www.thingiverse.com/download:455730)
- Left bracket (http://www.thingiverse.com/download:455726)
- Right bracket (http://www.thingiverse.com/download:455727)
- PWM controller board base (http://www.thingiverse.com/download:455729)
- Potentiometer holder (http://www.thingiverse.com/download:455728)
- Full clip (http://www.thingiverse.com/download:409393)
- Flat clip (http://www.thingiverse.com/download:416539)
- Pin (http://www.thingiverse.com/download:409394)
Follow me
on Twitter, Google+, Thingiverse, YouTube or by email to receive the
latest updates.
If you like my blog - please use the donate button :) This will help me making new stuff. THANK YOU!
If you like my blog - please use the donate button :) This will help me making new stuff. THANK YOU!
This is really a thing to consider, thank you very much regarding writing about this subject. . !
ReplyDeleteYou are more than welcome :)
Deletelighting diffuser
ReplyDelete