topbanner.gif
Login
Username

Password




Not a member yet?
Click here to register.

Forgotten your password?
Request a new one here.
Shoutbox
You must login to post a message.

10/17/2021 12:40 PM
Welcome, Ploni

10/15/2021 2:19 AM
merlot85, maycondelpiero and hoeltz, Welcome !

10/14/2021 10:06 AM
Thanks for the addition to the group. Seriously considering building a drum roaster along the lines of oldgrumpus's. Love the design and craftsmanship.

10/14/2021 4:00 AM
Morning, ar3mia ! and... coffee drink

10/12/2021 11:55 AM
Evan Slack and CupOfJoe, Welcome !

In Memory Of Ginny
Donations

Latest Donations
JackH - 25.00
snwcmpr - 10.00
Anonymous - 2.00
Anonymous - 5.00
Anonymous - 5.00
Users Online
Guests Online: 14

Members Online: 0

Total Members: 7,361
Newest Member: Ploni

View Thread

Who is here? 1 guest(s), CupOfJoe
 Print Thread
Testing Arduino UNO with bitwisetech / popc and MAX6675
zamunda
Hello,

Would like to test my coffee roaster with Arduino UNO and MAX6675 sensors (I am new to Arduino).
Managed to get the sensor working with an example sketch...also another example sketch for SSR.

Then would like to implement this example:
https://medium.co...a3334fd7d5
...but this did not work, get Modbus communication errors despite a lot of tweaking the settings.

So now I came across this sketch:
https://github.co...etech/popc

Seems to be configured per default for Arduino with MAX31855 sensors although I get the impression that it should also work with MAX6675.

Anyone had success with this setup?

Any idea/suggestion will be highly appreciated!

Regards
Edited by JackH on 08/06/2021 12:28 PM
renatoa
Worked some months in 2018 together with the author to make an ESP port of popc.
Succeeded, good code and logic inside, but MAX circuits usage limits its capabilities, at least for my pickiness, so finally switched to TC4.
zamunda
Hello Renatoa,

Thanks for your reply...I am tempted to purchase a TC4+ which has "everything you need" on board.
renatoa
Or, if you are a builder, as your MAX experiments shows, have a look at my TC4ESP thread/project.
TC4 heart with a smarter brain, full roast assistance without a computer tethered.
chaff
For the record, support in popc for ESP8266 was written into the code long before any activity in this forum. 'Worked with .. to port' must mean: 'The author spent a lot of time adding support for both NodeMCU and for MAX6675, upon demand, involving supporting many requested chanes to pinot definitions and debugging for the desired MAX6675 which needs a longer sampling period. Neither acknowlegement nor aprreciation was ever voiced.'

A cursory examination of git history will fully support the above.
zamunda
Hello,

I am testing further with Arduino and the sketches I mentioned above.

The one of Lukas:
https://medium.co...a3334fd7d5
...finally worked for me: by means of Modbus I get the BT within Artisan and with a SSR and slider I should be able to control the heater.

However, the slider works a bit weird in my opinion (I checked by connecting a bulb to the relay: when I set the slider to fe '50' the bulb starts flickering, if I set it to '0' it stays on and if I set it to '100' it stays off. That is, the opposite of what I would expect: at '100' the heater ("bulb") should be at full capacity and at '0', it should be off completely.

Is there an explaination for this "inverted" behaviour?

Thanks in advance!
zamunda attached the following images:
ssr.jpg screenshot_2021-08-07_at_162126.png screenshot_2021-08-07_at_141544.png screenshot_2021-08-07_at_162910.png

Edited by renatoa on 08/07/2021 11:19 AM
renatoa
The way how he controls the power modulation is not right.

The statement below in his code:


analogWrite(relay, (au16data[4]/100.0)*255);


... apparently should produce a right waveform, like in this image:
www.arduino.cc/wiki/54ef6da144b4531dd9ada686a7e67c56/pwm.gif

... thus different duty cycle for various power levels sent via register 4.

What is not right in the above approach is the frequency of pulses.
To obtain such effect you need use long pulses, in the 1-2 seconds ballpark, for the on-off cycle.
Instead, analogWrite command outputs a 490 Hz signal, which can't be used as is to control directly a SSR.
Good for a DC power control using a MOSFET, but not for AC using a triac.
zamunda
Hello Renatoa,

Thanks for your detailed response...so if I understand you right, I could use this SSR for DC-power controlling the fan (if I add a MOSFET)...but how to control the heater with a SSR/MODBUS then ?

In another setup, I do this with a python-script with a 1-second cycle: 70% heat = (70% ON, 30% OFF per second) but do not see how to achieve this here...And does this explain the "inverted" behaviour of the slider as mentioned?

Any further suggestions?

Thanks and regards,
Edited by zamunda on 08/07/2021 12:41 PM
zamunda
I think I found a (partial) answer here:
https://www.home-barista.com/roasting/getting-artisan-to-talk-to-arduino-t58234.html
renatoa
There are many answers in that thread, no time to sieve all of them, so please point to a specific post, if you want to find if their solution is appropriate for your case.

Please notice that some of the solutions in that thread are designed for 50 Hz mains. If you see delay(5) this means millisecond, and is the duration of 50 Hz quarter sine.
There is not direct equivalent code for 60 Hz mains, because that time interval is not an integer number, but 4.1666(6)... milliseconds. For 60 Hz another loop logic is required.
zamunda
Hello,

Based on the answers in the thread, I came up with this which worked for me in Artisan, that is, no modbus error, BT is read and slider seems to work, however, need further testing:

[Sorry for my ignorance but what is the difference between 50Hz and 60 Hz mains?]

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

// 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

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 to power MAX:
int vccPin = 3;
int gndPin = 2;

void setup() {
slave.begin( 19200); // 19200 baud, 8-bits, even, 1-bit stop
// use Arduino pins
pinMode(relay, OUTPUT);
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);

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

// heater control loop:
for (int i = 1; i <= 99; i++) {
if (i <= au16data[4])
digitalWrite(relay, HIGH);
else
digitalWrite(relay, LOW);
delay(5);
}
delay(500);
}
renatoa
I see an issue in the heater loop area, that code will never give you more than 50% effective power into the heater element.
Also, the delay(5) statement is for 50 Hz mains, else the results will be random, if you mount a bulb instead heater you should see flickering.
I would replace this part:


// heater control loop:
for (int i = 1; i <= 99; i++) {
...
delay(500);


with...

digitalWrite(relay, HIGH);
delay(au16data[4] * 10);
digitalWrite(relay, LOW);
delay((100 - au16data[4]) * 10 - 1);


This change should give you full 0-100% range control, and not dependent on mains frequency.
zamunda
Hello Renatoa,

Thanks for your reply and the improved snippet for the heat control, I just tested it and it works as expected (with bulb for now, will connect later to roaster). Works perfect, thanks!

I understand now what you mean with 50Hz vs 60Hz mains.

Also discovered that I had not connected the SSR correctly to the board: GND board should go to the "-" of the SSR, and PIN 9 of Arduino to the "+" of the SSR. Now works as expected, big thanks!

Post again here the updated version of the sketch:

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

// 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

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 to power MAX:
int vccPin = 3;
int gndPin = 2;

void setup() {
  slave.begin( 19200); // 19200 baud, 8-bits, even, 1-bit stop
  // use Arduino pins
  pinMode(relay, OUTPUT);
  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);

  //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
Actually, this code is just better, not perfect.
To improve it even further we need to know the duration of temperature acquisition (readCelsius), and the ModBus polling.
These time intervals aren't negligible, in the 250-300 ms ballpark, and the effect of ignoring them is an effective duty cycle lower than the desired power percent you send the command from Artisan. The error is about 20%, thus 100% sent from Artisan will mean 80% real heater power.
If your heating requirements will never exceed 80% HTR level, then you could be fine even with this solution. Just be aware there is an issue ticking, that could turn in a problem if one day you want more power.
zamunda
Hello Renatoa,

Thanks for this!

Today I tested this modbus-setup with a roaster and it worked quite well though I will do further testing later to confirm.

How could I determine/set the values for temperature acquisition and the ModBus polling?

And finally, if I would like to control also airflow of the DC-fan by means of a slider, what would be needed for that?
In another setup, I configured the L293N module on a Raspberry Pi to enable fancontrol with a Python script and Artisan slider/buttons (https://www.youtube.com/watch?v=2bganVdLg5Q). This works but I get some strange behaviour during the roast: after 1-2minutes, speed seems to drop spontaneously or stop completely. Maybe there is a flaw in my script. Also, the L293N has a 2A max per outlet, one could possibly set 2 outlet ins paralel to get a 4A max? I read that fans consume a lot of current specially during start.

In short: if I would like to control also airflow of the DC-fan with Arduino/Modbus, would the L293N module appropiate or is other hardware needed?

Thanks again for any advice on this!
Edited by zamunda on 08/09/2021 2:58 AM
renatoa
To transmit Fan slider values from Artisan to your board via ModBus you could allocate to Fan the register 5, and duplicate in Events dialog the write() command you have now for heater, but using register 5 instead 4, for the Air event. Check attached image.

Then, in your main loop code place a statement as below:

analogWrite(fan, (au16data[5]/100.0)*255);


... to send control PWM to L293N.

Fan is an output pin your choice, must be declared in setup() same way is the relay pin.


int relay = 9;
int fan = ...;
...
void setup() {
  slave.begin( 19200); // 19200 baud, 8-bits, even, 1-bit stop
  // use Arduino pins
  pinMode(relay, OUTPUT);
  pinMode(fan, OUTPUT);
...


To avoid big current issue, check how is DCFAN slew command implemented in TC4, applying changes in small 5% steps, even if you jump from 0 to 100%.
renatoa attached the following image:
image_2021-08-09_122752.png
zamunda
Hello Renatoa,

Thanks for explaining how to work with the fan and MODBUS. I did a quick test with a separate fan and this works...
Only thing I noticed is that the fan reacts only after 2-3 seconds when moving the air slider...

This is the sketch I have used right now (see below), tomorrow I will test it with a roaster...

Also will try to look into the TC4 code regarding the big current issue.

A big thanks again and I'll keep you posted!


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

// 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

void setup() {
  slave.begin( 19200); // 19200 baud, 8-bits, even, 1-bit stop
  // use Arduino pins
  pinMode(relay, OUTPUT);
  pinMode(fan, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
   
  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);
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);

  //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);
}
zamunda attached the following images:
screen_shot_2021-08-09_at_201530_2.png img_3448ss_1.jpg

Edited by zamunda on 08/09/2021 1:37 PM
zamunda
Hello,

Added some pics to previous post...
Edited by zamunda on 08/09/2021 4:05 PM
renatoa
The slew fan logic is here, at line 406:

https://github.co...reader.cpp

target is the final speed you want to reach
this routine should be called in the main loop, after any fan speed change, until target reached.
miyankizu
@renatoa @zamunda. I registered this forum because of your support each other. Personally I thank you , also Iím using same arduino sketch for my popper. Also realized that blink issue on the bulb on my trials. Iím not familiar with arduino programming but the sketch I have used before may give an idea to also to control with Artisan. The guy from Portuguese has written this code to control his whole system with roastlogger. I tried this system but because of roastlogger doesnít update for a long time, I want to change it with Artisan. And you are developing this system with fan control wow ThumbsUp I wish the sketch will also helps

https://medium.co...88ac60a37b

@zamunda is possible to share motor shield and arduino connection on basic drawing.
Edited by renatoa on 08/10/2021 6:03 AM
Jump to Forum:

Similar Threads

Thread Forum Replies Last Post
TC4+ Arduino coffee roaster shield (TC4-compatible) Dataloggers/Controllers/Rate of Rise Meters 229 03/24/2021 11:30 AM
SOLVED: Artisan says: "Arduino could not set channels" Dataloggers/Controllers/Rate of Rise Meters 9 01/24/2021 2:14 AM
Arduino and Artisan Dataloggers/Controllers/Rate of Rise Meters 4 01/21/2021 1:07 PM
Ametek Motor -Speed Control / Arduino Control??? Fluidbed Roaster 29 11/05/2020 1:32 AM
Heater Protection via Arduino Fluidbed Roaster 5 09/21/2020 9:41 AM
Homeroasters Association Logo, and all Content, Images, and Icons © 2005-2016 Homeroasters Association - Logos are the property of their respective owners.
Powered by PHP-Fusion Copyright © 2021 PHP-Fusion Inc
Released as free software without warranties under GNU Affero GPL v3
Designed with by NetriX