Welcome! Log In Create A New Profile

Advanced

Add a LED for the extrudor

Posted by Rony 
Add a LED for the extrudor
January 08, 2013 04:53AM
Hello.

I'd like to add a LED to show when the extrudor is hot (hottter than 210°C) or not.
I use a 2 colors LED, and I've connected this LED to the pin 4 and 5 to my Arduino Mega.

I put this code :
if(analogRead(TEMP_1_PIN) < 500)

{

digitalWrite(LED_TEMP_WAIT, HIGH);

digitalWrite(LED_TEMP_READY, LOW);

}

else

{

digitalWrite(LED_TEMP_WAIT, LOW);

digitalWrite(LED_TEMP_READY, HIGH);

}



But It doesn't work. Where do I have to put it to make it working ?

Here's my Tonokip_Firmware.pde :
[pastebin.com]


And my pins.h (MOTHERBOARD == 3) :
[pastebin.com]
Re: Add a LED for the extrudor
January 08, 2013 06:23AM
Did you define the pins as output? What does a voltage meter measure on the pins?


Generation 7 Electronics Teacup Firmware RepRap DIY
     
Re: Add a LED for the extrudor
January 08, 2013 06:30AM
I have never seen this firmware before so I may be wrong.

1) You say you want to monitor hotend, but you read TEMP_1_PIN, that appears to be heatbed (see lines 1347 & 1429)
2) You may use "current_raw" variable to avoid sampling TEMP_0_PIN twice
3) This functionality already appears to be somehow implemented (see digitalWrite(LED_PIN lines)

Edited 1 time(s). Last edit at 01/08/2013 06:33AM by miso.
Re: Add a LED for the extrudor
January 08, 2013 10:56AM
"Did you define the pins as output?"
No, I forgot. So I did it, and now it works !

But the green still on.
Which variable should I use ? current_raw or an other one ?

I just want to turn on the red color (pin 4) when it's under 200°C and the green (pin 5) when it's more than 200°C.
Re: Add a LED for the extrudor
January 09, 2013 04:59AM
Hello.

I tried with TEMP_0_PIN, it works so well !!
Thanks.
Re: Add a LED for the extrudor
January 09, 2013 05:23AM
using current_raw may be better from a compatibility standpoint. doing an analog sample with current firmwares is disruptive to the system and can lead to a crash or lack of sampling. the interrupt is used with sampling to improve adc performance, at least in two firmwares. doing a separate direct sample overrides the original sample request, disables the interrupt for adc response. when the sample is taken it is stored in the variable current_raw.


if(current_raw < 500)

{

digitalWrite(LED_TEMP_WAIT, HIGH);

digitalWrite(LED_TEMP_READY, LOW);

}

else

{

digitalWrite(LED_TEMP_WAIT, LOW);

digitalWrite(LED_TEMP_READY, HIGH);

}

Edited 1 time(s). Last edit at 01/09/2013 05:25AM by jamesdanielv.
Re: Add a LED for the extrudor
January 23, 2013 02:10AM
Ok.

So, how can I know the current_raw for 220°C ?
Re: Add a LED for the extrudor
January 23, 2013 04:36AM
By calling temp2analog(220)
Re: Add a LED for the extrudor
January 23, 2013 04:50AM
something like this
if(current_raw < 500)

replace with something like this:

int my_set_temp = 220 ;//set temp for led
if(current_raw < analog2temp(my_set_temp) )
{

digitalWrite(LED_TEMP_WAIT, HIGH);

digitalWrite(LED_TEMP_READY, LOW);

}

else

{

digitalWrite(LED_TEMP_WAIT, LOW);

digitalWrite(LED_TEMP_READY, HIGH);

}

this will take the stored analog value and run it thru the table to calculate actual temp or close to it.

Edited 2 time(s). Last edit at 01/23/2013 05:22AM by jamesdanielv.
Re: Add a LED for the extrudor
January 23, 2013 04:51AM
miso same page. thanks!
Sorry, only registered users may post in this forum.

Click here to login