Who is here? 2 guest(s)
 Print Thread
Coffee popper and brushless fan
Seroastito
Hello everyone, for a few days I've been trying to create a coffee roaster from a popcorn machine and control it with Artisan Scope. These will be the components:

PopCorn Machine 1200W - 220V
Arduino Uno R3
MAX 6675 K
SSR 40A - 220V
Brushless FAN
On the web I found a code that allows me to see the temperature with Artisan and manage the heating resistance with the SSR relay.
Later I added another code to control the fan but only with a 10K potentiometer.
My request is the following, what code do I have to add to also manage the Brushless Fan from Artisan?
I opted for a brushless motor because I used to do model airplanes and therefore I have it available and also because it has much more power than the brushed motor.
Now I'm waiting the arrival of TC4+ module and MAX485, to try to get something out.
Seroastito attached the following image:
screenshot_20241028-1750482.png
 
renatoa
Welcome !

Me too I was a lifetime model planes builder and flyer, so fully understand your choice.

You have to search for a servo library, there are many, including one in the standard Arduino libraries.
Such code issues PWM signals exactly as those used to control a BL motor ESC.
Include in your code and make a translation from Artisan values 0-100% to the range of numbers used by PWM code as input, probably pulse width microseconds, I guess. Something like this:


#include <Servo.h>
Servo myservo;
...
servo.attach(pin)
...
servo.writeMicroseconds(us)


If you have issues, don't hesitate to ask.
Edited by renatoa on 10/31/2024 3:43 AM
 
Seroastito
In the last few days I have started studying Arduino Language, but for now I'm still in kindergarten let's say lol
I use this schetch and with it I can read the temperature and controll the heat, but I can't controll the ESC. In the picture I use the servo as Potentiometer.

#include <max6675.h>
#include <ModbusRtu.h>
#include <Servo.h>

Servo ESC;

// data array for modbus network sharing
uint16_t au16data[16] = {
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1
};

/**
    Modbus object declaration
    u8id : node id = 0 for master, = 1..247 for slave
    u8serno : serial port (use 0 for Serial)
    u8txenpin : 0 for RS-232 and USB-FTDI
                 or any pin number > 1 for RS-485
*/
Modbus slave(1, 0, 0); // this is slave @1 and RS-232 or USB-FTDI

// Pins for thermocouple MAX6675
int thermoDO = 6;
int thermoCS = 5;
int thermoCLK = 4;

MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);

// declare variable for Arduino pin connected to solid state relay (SSR)
int relay = 9;

// declare variables for Arduino pins connected to fan controller (L293N)
int fan = 10; // ENA of L239N
int in1 = 11; // IN1 of L239N
int in2 = 12; // IN1 of L239N

// declare variables for Arduino pins to power MAX6675:
int vccPin = 3; // 5v power of MAX6675
int gndPin = 2; // gnd of MAX6675

// slew rate limitations for fan control
#define SLEW_STEP 10 // increase in steps of 10% for smooth transition
int target = 0;
int current = 0;
int potValue;  // value from the analog pin
void slew_fan() { // limit fan speed increases
  target = ((au16data[5] / 100.0) * 255);
  if ( target < current ) { // ramping down, so check rate
    uint8_t delta = current - target;
    if ( delta > SLEW_STEP ) // limit the step size
      delta = SLEW_STEP;
    analogWrite(fan, (current - delta ));
    current = current - delta;
  }
  else if ( target > current ) { // ramping up, so check rate
    uint8_t delta = target - current;
    if ( delta > SLEW_STEP ) // limit the step size
      delta = SLEW_STEP;
    //write current fan value for air control
    analogWrite(fan, (current + delta ));
    current = current + delta;
  }
}


void setup() {
  slave.begin( 19200); // 19200 baud, 8-bits, even, 1-bit stop
  // use Arduino pins
  ESC.attach(8,1000,2000);
  pinMode(relay, OUTPUT);
  pinMode(fan, OUTPUT);
  //fan direction can be reversed by interchanging values for in1 and in2
  pinMode(in1, OUTPUT); digitalWrite(in1, HIGH);
  pinMode(in2, OUTPUT); digitalWrite(in2, LOW);

  pinMode(vccPin, OUTPUT); digitalWrite(vccPin, HIGH);
  pinMode(gndPin, OUTPUT); digitalWrite(gndPin, LOW);
  delay(500);
}

void loop() {
  //write current thermocouple value
  au16data[2] = ((uint16_t) thermocouple.readCelsius() * 100);

  //write current fan value for air control
  // analogWrite(fan, (au16data[5] / 100.0) * 255);
  slew_fan();
  potValue = analogRead(A0);   // reads the value of the potentiometer (value between 0 and 1023)
  potValue = map(potValue, 0, 1023, 0, 180);   // scale it to use it with the servo library (value between 0 and 180)
  ESC.write(potValue);    // Send the signal to the ESC

  //poll modbus registers
  slave.poll( au16data, 16 );

  // heater control:
  digitalWrite(relay, HIGH);
  delay(au16data[4] * 10);
  digitalWrite(relay, LOW);
  delay((100 - au16data[4]) * 10 - 1);
}
 
renatoa
Use a separate register on MODBUS pseudo-device to get fan values from Artisan instead potentiometer, similar to how you get heater value.
 
Seroastito
Please, can you show me an example how is the register? I'm sorry but I copy the code from internet so I don't really know how to write the register
 
renatoa
First... show us the Artisan screen with modbus configuration.
From the code, I guess that register 2 is for temperature, and register 4 for heater.

Similar to register 4, you should map in Artisan another register, for fan, say register 5... and in this case, instead the actual ESC mapping and control code...


potValue = map(potValue, 0, 1023, 0, 180);   // scale it to use it with the servo library (value between 0 and 180)
  ESC.write(potValue);    // Send the signal to the ESC


you will have ...


potValue = map(au16data[5], 0, 100, 0, 180);   // scale it to use it with the servo library (value between 0 and 180)
  ESC.write(potValue);    // Send the signal to the ESC
 
Seroastito

Quote

renatoa wrote:

First... show us the Artisan screen with modbus configuration.
From the code, I guess that register 2 is for temperature, and register 4 for heater.

Similar to register 4, you should map in Artisan another register, for fan, say register 5... and in this case, instead the actual ESC mapping and control code...


potValue = map(potValue, 0, 1023, 0, 180);   // scale it to use it with the servo library (value between 0 and 180)
  ESC.write(potValue);    // Send the signal to the ESC


you will have ...


potValue = map(au16data[5], 0, 100, 0, 180);   // scale it to use it with the servo library (value between 0 and 180)
  ESC.write(potValue);    // Send the signal to the ESC

You are a genius!!!
As soon as I got home I entered the code as you suggested and it worked!
Now I have to refine it a bit because the motor responds after about 5 seconds, after each command and this is a problem for a PID roasting LOL. The temperature probe does not show any value. And when I have the SSR available again (tomorrow or the day after tomorrow), I will verify that it works correctly.
I attach the photos of Artisan and the new code that allows me to control the brushless motor.
Thank you so much again!

#include <max6675.h>
#include <ModbusRtu.h>
#include <Servo.h>

Servo ESC;

// data array for modbus network sharing
uint16_t au16data[16] = {
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1
};

/**
    Modbus object declaration
    u8id : node id = 0 for master, = 1..247 for slave
    u8serno : serial port (use 0 for Serial)
    u8txenpin : 0 for RS-232 and USB-FTDI
                 or any pin number > 1 for RS-485
*/
Modbus slave(1, 0, 0); // this is slave @1 and RS-232 or USB-FTDI

// Pins for thermocouple MAX6675
int pinGND = 2;
int pinVCC = 3;
int pinDO = 4;
int pinCS = 5;
int pinCLK = 6;

MAX6675 thermocouple(pinCLK, pinCS, pinDO);

// declare variable for Arduino pin connected to solid state relay (SSR)
int relay = 9;

// declare variables for Arduino pins connected to ESC fan controller
int fan = 10; // pin bianco ESC


// slew rate limitations for fan control
#define SLEW_STEP 10 // increase in steps of 10% for smooth transition
int target = 0;
int current = 0;
int potValue = 40;  // value from the analog pin
void slew_fan() { // limit fan speed increases
  target = ((au16data[5] / 100.0) * 255);
  if ( target < current ) { // ramping down, so check rate
    uint8_t delta = current - target;
    if ( delta > SLEW_STEP ) // limit the step size
      delta = SLEW_STEP;
  }
  else if ( target > current ) { // ramping up, so check rate
    uint8_t delta = target - current;
    if ( delta > SLEW_STEP ) // limit the step size
      delta = SLEW_STEP;
    //write current fan value for air control
  }
}

void setup() {

  slave.begin( 19200); // 19200 baud, 8-bits, even, 1-bit stop
  // use Arduino pins
  ESC.attach(10,1000,2000);
  pinMode(relay, OUTPUT);
  pinMode(fan, OUTPUT);
  delay(100);
}

void loop() {
  {
  //write current thermocouple value
    au16data[2] = ((uint16_t) thermocouple.readCelsius() * 100);
   
  // analogWrite(fan, (au16data[5] / 100.0) * 255);
  slew_fan();
  potValue = map(au16data[5], 0, 100, 0, 180);   // scale it to use it with the servo library (value between 0 and 180)
  ESC.write(potValue);    // Send the signal to the ESC
  slave.poll( au16data, 16 );

  // heater control:
  digitalWrite(relay, HIGH);
  delay(au16data[4] * 10);
  digitalWrite(relay, LOW);
  delay((100 - au16data[4]) * 10 - 1);
}
}
Seroastito attached the following images:
1_assegnazione_dispositivo_modbus.jpg 3_eventi_cursore.jpg 3_eventi_config.jpg 2_configurazione_porte.jpg 2_configurazione_porte_s7.jpg 2_configurazione_porte_etbt.jpg
 
Seroastito
Finally I connected everything and everything works, the brushless run, the temperature is right and the SSR works fine. Now I just need to find the right brushless fan.
I found some brushless blower and vacuum brushless fan with ESC integrated, but my doubt is: can I controll this ESC/motor with Arduino?? Do you have any experiences with these products?
https://a.aliexpr...m/_EzAKyCH
https://a.aliexpr...m/_EIyjyJx
https://a.aliexpr...m/_EzX9T8Z
https://a.aliexpr...m/_EHfcnhL
 
renatoa
These are no more model plane motors, thus the control timing is unknown, probably not servo style.
If you don't have exact intel about the control PWM specs, they are a lottery.
 
Seroastito

Quote

renatoa wrote:

These are no more model plane motors, thus the control timing is unknown, probably not servo style.
If you don't have exact intel about the control PWM specs, they are a lottery.

You are right, I would like to buy a 2200kvengine and 12V 20A power supply but I can't find a suitable fan to replace the popper one... one last thing do you by any chance know how I can increase the reactivity of the engine? Responds after 3-5 seconds.
 
renatoa
For reactivity increase SLEW_STEP.

The popper motor has 8-12000 RPM, depending on build.
Probably 2200kv would suit you, if using 12V... will run around 50% throttle.
Why replace the fan? Get a 2.3mm shaft motor and use same fan.
 
Seroastito
In the end I ordered, a 2200kv brushless, 40A Power supply and will see what comes out! I will keep you updated, in the meantime thank you very much for all your valuable advice!
 
renatoa
Good point about power supply capable of great amperage... you should expect a draw in the 8-10 Amps ballpark.
The popper motors current is around 3 Amps, from 24V sources.

Please also note that the model plane motors aren't designed to run continuously, many minutes, at constant power, except those used in drones.
Even drone motors are used 90% of time in the 40-60% throttle range.
For cheap motors consider the bearings life somewhere in the tens of hours range, not so many... I had broken bearings even after 10 hours.
They are cheap and simply to replace though...
 
Seroastito

Quote

renatoa wrote:

Good point about power supply capable of great amperage... you should expect a draw in the 8-10 Amps ballpark.
The popper motors current is around 3 Amps, from 24V sources.

Please also note that the model plane motors aren't designed to run continuously, many minutes, at constant power, except those used in drones.
Even drone motors are used 90% of time in the 40-60% throttle range.
For cheap motors consider the bearings life somewhere in the tens of hours range, not so many... I had broken bearings even after 10 hours.
They are cheap and simply to replace though...


This engine that I have bought appears to be one of the cheap ones, I build this roast more as a hobby and to try roasted coffee with the air, because my main roast is the Kaleido M2 Pro, and the BocaBoca250. Considering that the maximum quantity I want to roast is 100gr, I hope to use it at maximum 50% throttle. Then there is the problem of the limit of 1200W of the heater. I really hope it is enough for me, otherwise I would not know what to use...
https://share.tem...Y98reTQSlA
Edited by renatoa on 11/04/2024 12:19 PM
 
Seroastito
I could not resist and today I tried to do roast the first 60grams of Honduras (cheap coffee). I definitely went beyond the first crack and lost 18%, but the goal is not to drink it but to verify that everything is working correctly!
First Crack at 198°C, I forgot to crush charge button on Artisan but the important thing is that everything is recorded. Artisan Lower or turn up the engine revs 5 seconds after my command unfortunately ... We will see how it goes with the new brushless engine and the pyrex glass.
i.ibb.co/5sZd2CH/PXL-20241105-135730372.jpg

Please, change the image links as I did above, pointing each to the jpg files, and enclosed in img tags.
https://ibb.co/B46Hy9P
https://ibb.co/h9sNds6
https://ibb.co/dc92wKH
https://ibb.co/fxJ5ShZ
Edited by renatoa on 11/05/2024 12:13 PM
 
renatoa
You can mark events later, after the roast, just right click on the curve, at desired time, and add event to place there.

Why not drink? Shock
 
Seroastito

Quote

renatoa wrote:

You can mark events later, after the roast, just right click on the curve, at desired time, and add event to place there.

Why not drink? Shock

Degassing! 😅 Saturday I will absolutely try it with the super Cafelat Robot!
 
Jump to Forum: