Coffee Roaster from Popcorn Popper Brushless FAN

good morning 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 ESC - 30A
  • Brushless FAN (2200kv - 12V which is used in RC Airplanes)
    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.
    I attach some photos.
#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);
}


Is the motor controller waiting for PWM or just HIGH/LOW? If PWM, put the white wire on a PWM pin, labeled with a tilde/squiggly.

Again, if PWM, find a sketch to "fade" an LED to practice PWM control.

Thanks for the tip, tomorrow I will try again and I'll let you know how it went. Meanwhile, this evening I try to study the programming language. My big difficulty is programming on Arduino and then configuring Artisan to recognize everything😅

Unfortunately my inability to program arduino, forced me to buy a TC4+ board, in theory this will be able to control both the brushless motor and the SSR relay directly from Artisan Scope. I'll wait for it to arrive.

While you're at it, consider getting a copy of the Arduino Cookbook and while going through it cover to cover. Try out any projects that catch your interest.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.