Welcome! Log In Create A New Profile

Advanced

[TeaCup Firmware] : to add a fan control

Posted by jojolapatade 
[TeaCup Firmware] : to add a fan control
February 19, 2013 05:46PM
Hi,
I would like to order a fan attached to the trolley X.
I read the wiki and did some research on google, but my tests have failed.
I use the card GEN7 (1.4) with ATMEGA1284P. I know that I have to add a small additional card to control the fan via a MOSFET (SevenSwitch).

I read on wiki that it was necessary to use PB6 (pin 7 at ATmega), and can be recovered via the connector conn6 : pin 1 et 6 (GND). I read the documentation of ATMEGA644P and there isn't PWM output available on this pin. This output is PWM available only on ATMEGA1284P.

Out in the file arduino.h I've read that ATMEGA1284P is the same definition file that ATmega644 microcontroller: # include "arduino_644.h"

I do not understand why it is called the pin PB6 in the wiki ... but I'm curious to know how to use PB6.

I tried using a pin on the connector available CONN4 (extension board) PWM function which is compatible on both microcontrollers : PD6.
I do my tests with the pin PD6 for now

I changed only the file config.h like this:
(My changes are always defined with this comment: // to add a fan)


#ifndef DEFINE_HEATER
#define DEFINE_HEATER(...)
#endif

// name port pwm
DEFINE_HEATER(extruder, DIO4, 1)
DEFINE_HEATER(bed, DIO3, 1)
DEFINE_HEATER(fan, DIO14, 1) // to add a fan
...
#define HEATER_EXTRUDER HEATER_extruder
#define HEATER_BED HEATER_bed
#define HEATER_FAN HEATER_fan // to add a fan


After compiled and programed the microcontroller, I test the command M106 S255 which is well understood by the firmware (responds with ok) but pin 20 of ATmega remains in the low state.

Can someone help me to activate this function.
Sincerely,
Jonathan
Re: [TeaCup Firmware] : to add a fan control
February 20, 2013 06:50AM
#define HEATER_FAN HEATER_fan // to add a fan

These comments aren't a good idea. Not sure about it, but they might be considered to be part of the macro.

Other than that your definition looks fine. I'd try with defining the extruder on pin DIO14 to look wether you get a signal. Admittedly, pin names are a bit of a mess, mostly due to historical reasons.


Generation 7 Electronics Teacup Firmware RepRap DIY
     
Re: [TeaCup Firmware] : to add a fan control
February 20, 2013 03:38PM
Comments after or even inside macros are fine, comments are stripped out before preprocessor directives are parsed.
Re: [TeaCup Firmware] : to add a fan control
February 20, 2013 04:25PM
Hi,
I put the two lines I added comments to the fan and replace DIO4 by DIO14.
DEFINE_HEATER(extruder, DIO14, 1)

What is surprising is the operation that I get:
PD6 pin (pin 20 of ATmega) work with PWM wave but led the extructeur PB4 yes, but that's just a load left on the pin (initialization) as soon as I make a measurement PB4 remains at zero.

This PWM signal is adjusted via the temperature sensor of the extruder which is normal.

Edited 1 time(s). Last edit at 02/21/2013 12:54AM by jojolapatade.
Re: [TeaCup Firmware] : to add a fan control
February 20, 2013 04:48PM
In file gcode_process.c : the fonction for the g-code M106 (same M104)
case 106:
//? --- M106: Set Fan Speed ---
//?
//? Example: M106 S120
//?
//? Control the cooling fan (if any).
//?

#ifdef ENFORCE_ORDER
// wait for all moves to complete
queue_wait();
#endif
#ifdef HEATER_FAN
if ( ! next_target.seen_S)
break;
temp_set(HEATER_FAN, next_target.S);
if (next_target.S)
power_on();
#endif
break;


t uses a function that needs to check a temperature ... There is not a problem by any chance?


/// specify a target temperature
/// \param index sensor to set a target for
/// \param temperature target temperature to aim for
void temp_set(temp_sensor_t index, uint16_t temperature) {
if (index >= NUM_TEMP_SENSORS)
return;

// only reset residency if temp really changed
if (temp_sensors_runtime[index].target_temp != temperature) {
temp_sensors_runtime[index].target_temp = temperature;
temp_sensors_runtime[index].temp_residency = 0;
#ifdef TEMP_INTERCOM
if (temp_sensors[index].temp_type == TT_INTERCOM)
send_temperature(temp_sensors[index].temp_pin, temperature);
#endif
}
Re: [TeaCup Firmware] : to add a fan control
February 21, 2013 04:49PM
We need to define a temperature sensor for the NULL function works ... read the comment definition of temperature sensors in the config.h file

TT_INTERCOM and TT_NONE don't use a pin, insert AIO0 anyways to keep the compiler happy. The pin won't be used in this case.

I admit it was not easy to understand but the main is that it works ... I hope this information will else.
And I also found the explanation to this address GIT

My edits applied to config.h below:

#ifndef DEFINE_TEMP_SENSOR
#define DEFINE_TEMP_SENSOR(...)
#endif

// name type pin additional
DEFINE_TEMP_SENSOR(extruder, TT_THERMISTOR, AIO1, THERMISTOR_EXTRUDER)
DEFINE_TEMP_SENSOR(bed, TT_THERMISTOR, AIO0, THERMISTOR_BED)
DEFINE_TEMP_SENSOR(fan, TT_INTERCOM, AIO0, TT_NONE)

.....

#ifndef DEFINE_HEATER
#define DEFINE_HEATER(...)
#endif

// name port pwm
DEFINE_HEATER(extruder, DIO4, 1)
DEFINE_HEATER(bed, DIO3, 1)
DEFINE_HEATER(fan, DIO14, 1)

...

#define HEATER_EXTRUDER HEATER_extruder
#define HEATER_BED HEATER_bed
#define HEATER_FAN HEATER_fan



Now I can have a PWM fan control and control the flow of air FAN

Good luck to all, thank you

Edited 1 time(s). Last edit at 02/21/2013 05:09PM by jojolapatade.
Re: [TeaCup Firmware] : to add a fan control
February 22, 2013 07:43AM
case 106:
...
temp_set(HEATER_FAN, next_target.S);
Yes, this is wrong. It was fixed with this commit: [github.com] Also, TT_NONE is gone now.

In case something goes wrong it's always a good idea to update sources before attempting to fix them. smiling smiley


Generation 7 Electronics Teacup Firmware RepRap DIY
     
Re: [TeaCup Firmware] : to add a fan control
October 23, 2013 03:50PM
Hi,
Just to indicate that the links to github are wrong : you have to change "triffid" by "traumflug" like this :
https://github.com/traumflug/Teacup_Firmware/commit/6f2ec09837231edd6f000cd4ae1c1bf6888d62c7
Regards,

Thierry


Prusa V2 + Ramps 1.4 (Marlin Firmware) avec autolevelling bed, écran LCD et alimentation à 24V + Raspberry Pi Model B (pour impression autonome) / Pronterface + Slic3r sous Ubuntu 14.04 / Niveau : Pratiquant / Localisation : Lézignan-Corbières (Aude, France)
Re: [TeaCup Firmware] : to add a fan control
April 17, 2014 02:39PM
I am sorry but i cannot understand how to control the fan, i have done As says jojolapatade


But all time says this


Edited 1 time(s). Last edit at 04/17/2014 04:39PM by alfadex.
Attachments:
open | download - config.h (22.8 KB)
Re: [TeaCup Firmware] : to add a fan control
April 18, 2014 05:52AM
No idea where you got this definition line from, but TT_NONE is gone for a long time now. If you look into the comments right above the line you also read that TT_INTERCOM is for Generation 3 Electronics, only.

This comment also tells me that your version of Teacup sources is very old. We have lookahead now!

Please get new sources and start over with a new config.h (keep the old one around for steps/mm values). You'll find an example for a fan definition in config.default.h (search for "fan").


Generation 7 Electronics Teacup Firmware RepRap DIY
     
Re: [TeaCup Firmware] : to add a fan control
April 19, 2014 05:24AM
I upload the new firmware but all motor speed is very low now and i cannot control micro stepping at all.


And i cannot control fan speed, i sent m106 s255 but on oscilloscope nothing is moving, i have 0 V.
Oscilloscope is connected here

Attachments:
open | download - config.h (25.4 KB)
Re: [TeaCup Firmware] : to add a fan control
April 19, 2014 09:11AM
Big mistake, DIO14 is PD6 and not PB6.Like photo . I see now PWM on oscillator.



But why motor speed is so low. It is like very high micro stepping, but even if i change micro stepping nothing change

And one more question ,i am trying to open SevenSwitch.sch from Github with Eagle, but says error , I tried with Kicad but nothing, .Wcich program can open those files?

After printing, i notice everything is very slowww when i upload new version teachup. Even if i sent m106 s0 fan stop arounf after 8 second. I suppose something is happening with atmega crystal

Edited 2 time(s). Last edit at 04/19/2014 04:24PM by alfadex.
Re: [TeaCup Firmware] : to add a fan control
April 20, 2014 04:53AM
Quote
alfadex
But why motor speed is so low. It is like very high micro stepping, but even if i change micro stepping nothing change

Did you copy MAXIMUM_FEEDRATE_{XYZE} values from the old config.h? No change in this area. Also, microstepping is set on the hardware. In config.h there is only one correct value for STEPS_PER_M_{XYZE} which reflects your hardware. A wrong STEPS_PER_M value leads to wrong movement distances.


Quote
alfadex
And one more question ,i am trying to open SevenSwitch.sch from Github with Eagle, but says error , I tried with Kicad but nothing, .Wcich program can open those files?

It's gEDA: [reprap.org]

Quote
alfadex
I suppose something is happening with atmega crystal

If your crystal would ever decide to run slower than specified, baud rates would become slower, too, and you couldn't communicate with the board at all.


Generation 7 Electronics Teacup Firmware RepRap DIY
     
Re: [TeaCup Firmware] : to add a fan control
April 20, 2014 09:41AM
MAXIMUM_FEEDRATE_{XYZE} values was exactly the same
I only copy STEPS_PER_M_{XYZE} and define (XYZE)_(MIN/MAX from confic.h. Nothing else.

Before upload the new version the speed was this
[www.youtube.com]

But now is this
[www.youtube.com]

Distances and micro stepping are adjusted as before. But it is very slow (xyze).Slic3r speeds are all default
I tried to copy only config.h from old version teachup ,to new version ,but it says this


x,y,z are adjusted 1/8 and extruder is 1/16.Is it better to adjust to 1/2?
Re: [TeaCup Firmware] : to add a fan control
April 21, 2014 07:29AM
Quote
alfadex
I tried to copy only config.h from old version teachup

Playing around doesn't help. Please follow instructions, see what you get: [reprap.org] Send G-code manually to rule out slicer issues. Then adjust one value a time: [reprap.org]


Generation 7 Electronics Teacup Firmware RepRap DIY
     
Re: [TeaCup Firmware] : to add a fan control
October 12, 2015 08:27PM
On my printer (Arduino Mega2560 clone, RAMPS 1.4, Teacup firmware), the fan started working after I added
DEFINE_HEATER(fan, PH6, 1)
into config.h
The fan is connected to D9, controlled by M106 P2 Sxxx.

Edited 1 time(s). Last edit at 10/12/2015 08:29PM by fix_it_alex.
Re: [TeaCup Firmware] : to add a fan control
October 13, 2015 06:21AM
Glad to see you got it working :-)


Generation 7 Electronics Teacup Firmware RepRap DIY
     
Sorry, only registered users may post in this forum.

Click here to login