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/26/2021 1:55 AM
Welcome, Ukwoody, liamsmith, timbarnes, SydHagen and GISpoIRiS !

10/25/2021 3:16 PM
MendoEB, Welcome to HRO! Welcome

10/21/2021 2:41 AM
muckymuck, mckinleyharris and williamjonex welcome cup

10/19/2021 6:22 AM
Welcome tarunk!

10/17/2021 12:40 PM
Ploni and nader fouad, 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: 15

Members Online: 0

Total Members: 7,377
Newest Member: Ukwoody

View Thread

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

Quote

renatoa wrote:

You can't use the same serial comm port for both BT and USB.
Some switching is required, at least one of the lines.


Thank you Renatoa, I was aware of that, I do not have the board connected per USB when trying to upload.

Update: ah, I understand I guess, uploading a sketch can only be done per USB and in that case pin 1 and 2 of BT should be temporarily disconnected.
Edited by zamunda on 08/20/2021 2:26 AM
zamunda

Quote

zamunda wrote:

Quote

renatoa wrote:

You can't use the same serial comm port for both BT and USB.
Some switching is required, at least one of the lines.


Thank you Renatoa, I was aware of that, I do not have the board connected per USB when trying to upload.

Update: ah, I understand I guess, uploading a sketch can only be done per USB and in that case pin 1 and 2 of BT should be temporarily disconnected.


Made some progress, found this video very helpfull:

1) Was able to set AT-commands in order to adjust defaults for BAUD-rate, name, password, etc
2) Luckily for my model, no voltage reducer was needed (RX accepts 3-6V)
3) Found out that for AT-mode, jumpers should be: RX-RX, TX-TX, in normal mode: RX-TX, TX-RX
4) Can connect to BT with my Mac, however, adjusting CONFIG within Artisan still gives me a modbus communication error after a while, no temp readings still.


Somewhere in the video is said that the HC-06 is not compabible with Apple but elsewhere I read that only counts for IOS, Mac OS X should be good. Can anyone confirm that?

Thanks and regards,
Bert
zamunda
Pic of BT model
zamunda attached the following image:
screenshot_2021-08-20_at_185039.png
zamunda
Hello
I set the BAUD rate of the HC-06 tot 19200 just like in the sketch:
...
void setup() {
slave.begin( 19200); // 19200 baud, 8-bits, even, 1-bit stop
...
I connect the Mac to BT, connection succesfull, when I start Artisan, the blue led stays on fixed indicating Artisan is connected via BT to Arduino. However, after a while I (5-6 seconds) I get "Modbus communication Error"...

Any ideas how to proceed/debug further?

Thanks and regards,
renatoa
Is the BT speed in Artisan the same as for usb ?
zamunda
Hello Renatoa,

Thanks for your reply. The image shows the working MODBUS configuration per USB...the HC-06 has a 9600 baudrate per default so I set this with an AT-command to 19200 as well and parity set to "N". The modbus configuration error does not show up immediately, it takes about 5-6 seconds....
zamunda attached the following image:
screenshot_2021-08-21_at_141117.png

Edited by zamunda on 08/21/2021 8:00 AM
renatoa
There is a serial log dialog in Artisan Help menu, please ca you check there if the information that travels is properly decoded and looks understandable ?
If you see graphical chars without any meaning, this usually means baud rate mismatch.
zamunda
Hello Renatoa,

It says this:
version = 2.4.4

4 15:44:13.077 MODBUS readSingleRegister : /dev/tty.ZamundaRoasterBT-DevB,19200,8,N,1,2.0 || Slave = 1 || Register = 2 || Code = 3 || Rx = None

3 15:44:04.074 MODBUS readSingleRegister : /dev/tty.ZamundaRoasterBT-DevB,19200,8,N,1,2.0 || Slave = 1 || Register = 2 || Code = 3 || Rx = None

2 15:43:55.077 MODBUS readSingleRegister : /dev/tty.ZamundaRoasterBT-DevB,19200,8,N,1,2.0 || Slave = 1 || Register = 2 || Code = 3 || Rx = None

1 15:43:46.077 MODBUS readSingleRegister : /dev/tty.ZamundaRoasterBT-DevB,19200,8,N,1,2.0 || Slave = 1 || Register = 2 || Code = 3 || Rx = None
renatoa
And the same dialog for modbus over usb connection ?
zamunda

Quote

renatoa wrote:

And the same dialog for modbus over usb connection ?


No, RX is not empty, it says:
version = 2.4.4

81 19:09:51.014 MODBUS readSingleRegister : /dev/tty.usbserial-FD130,19200,8,N,1,2.0 || Slave = 1 || Register = 2 || Code = 3 || Rx = 2200

80 19:09:51.014 MODBUS readActiveRegisters : /dev/tty.usbserial-FD130,19200,8,N,1,2.0 || Slave = 1 || Register = 2 || Code = 3 || Rx# = 1 results

79 19:09:51.014 cache reading : Slave = 1 || Register = 2 || Rx = 2200

78 19:09:48.015 MODBUS readSingleRegister : /dev/tty.usbserial-FD130,19200,8,N,1,2.0 || Slave = 1 || Register = 2 || Code = 3 || Rx = 2200

77 19:09:48.015 MODBUS readActiveRegisters : /dev/tty.usbserial-FD130,19200,8,N,1,2.0 || Slave = 1 || Register = 2 || Code = 3 || Rx# = 1 results

76 19:09:48.015 cache reading : Slave = 1 || Register = 2 || Rx = 2200

75 19:09:45.017 MODBUS readSingleRegister : /dev/tty.usbserial-FD130,19200,8,N,1,2.0 || Slave = 1 || Register = 2 || Code = 3 || Rx = 2200
zamunda attached the following image:
screenshot_2021-08-21_at_190851.png
zamunda

Quote

zamunda wrote:

Quote

renatoa wrote:

And the same dialog for modbus over usb connection ?


No, RX is not empty, it says:
version = 2.4.4

81 19:09:51.014 MODBUS readSingleRegister : /dev/tty.usbserial-FD130,19200,8,N,1,2.0 || Slave = 1 || Register = 2 || Code = 3 || Rx = 2200

80 19:09:51.014 MODBUS readActiveRegisters : /dev/tty.usbserial-FD130,19200,8,N,1,2.0 || Slave = 1 || Register = 2 || Code = 3 || Rx# = 1 results

79 19:09:51.014 cache reading : Slave = 1 || Register = 2 || Rx = 2200

78 19:09:48.015 MODBUS readSingleRegister : /dev/tty.usbserial-FD130,19200,8,N,1,2.0 || Slave = 1 || Register = 2 || Code = 3 || Rx = 2200

77 19:09:48.015 MODBUS readActiveRegisters : /dev/tty.usbserial-FD130,19200,8,N,1,2.0 || Slave = 1 || Register = 2 || Code = 3 || Rx# = 1 results

76 19:09:48.015 cache reading : Slave = 1 || Register = 2 || Rx = 2200

75 19:09:45.017 MODBUS readSingleRegister : /dev/tty.usbserial-FD130,19200,8,N,1,2.0 || Slave = 1 || Register = 2 || Code = 3 || Rx = 2200


What is/does "RX" here?

So what I understand via USB temp value is passed over RX, per BT it does not pass anything.

Any ideas?

Thanks!
renatoa
An error occured during modbus reading or decoding.
Check modbusport.py, in 2.4.x src\artisanlib folder
zamunda

Quote

renatoa wrote:

An error occured during modbus reading or decoding.
Check modbusport.py, in 2.4.x src\artisanlib folder


Thanks for your reply. I am on Mac OS x and can't find such a folder.

I am a bit lost: I tried several configs also this from:
https://www.home-barista.com/roasting/getting-artisan-to-talk-to-arduino-t58234-20.html

Behaviour is the same for all of them, over USB, temp is read and passed to Artisan, no problem, once connected over BT, I get the Modbus error, that is, RX = none.

I am quite sure the BT is ok, did several tests via basic scripts and I can communicate over BT from the module to me laptop.

Is there another point I am missing here maybe? Over BT I power Arduino via USB to an iPhone adapter (5V, 1A). Could that be critical? Should I power Arduino by the dedicated power inlet and not over USB?

Any other suggestions are welcome!
Thanks
zamunda
Hello,

Finally, I achieved to connect over Modbus/Bluetooth, I had to change the sketch by assigning PINs to RX/TX other than the dedicated PINs on the Arduino and use SoftwareSerial.

The following sketch worked for me:


#include <max6675.h>
#include <ModbusRtu.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(7, 8); // RX, TX

// 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, mySerial, 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;

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() {
  mySerial.begin(19200); // Soft Serial used for communication through Bluetooth module HC-06
  slave.start( ); // 19200 baud, 8-bits, even, 1-bit stop
  // use Arduino pins
  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();

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

Based on the sketch above, I did some roasting with batches of 100gram. I think the result comes out quite nice, from Artisan I can control heat and air conveniently. I mounted the roaster on a wooden box which I can open later to check wirings etc. Bluetooth also works well.
Also built a simple chaff collector which sits on top of the roaster which can be emptied from time to time.

BTW: I disabled the "slew-function" withing the sketch for now since this "messed up" de loop-functionality within Arduino. So far, I did not experience overload problems (which was something this function should help to prevent)

Obviously there is much room for improvement but this was/is an (exciting) learning-by-doing-and-falling process.

Hardware used in this build:
- Princess Popcorn popper (1200W/220V)
- MAX6675 sensor for temp readings
- Arduino UNO (3)
- (Manual) DC voltage adapter for fan
- L298N DC-Motor Controller for slider-controlling the fan from Artisan
- Solid state relay for controlling the heat element
- Bluetooth module HC06 for wireless connection from Artisan to roaster
- DC-adapter iPhone for Arduino

Big thanks to everyone on this forum, if you have any questions/suggestions, please let me know.

Quote

zamunda wrote:

Hello,

Finally, I achieved to connect over Modbus/Bluetooth, I had to change the sketch by assigning PINs to RX/TX other than the dedicated PINs on the Arduino and use SoftwareSerial.

The following sketch worked for me:


#include <max6675.h>
#include <ModbusRtu.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(7, 8); // RX, TX

// 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, mySerial, 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;

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() {
  mySerial.begin(19200); // Soft Serial used for communication through Bluetooth module HC-06
  slave.start( ); // 19200 baud, 8-bits, even, 1-bit stop
  // use Arduino pins
  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();

  //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:
4_17.jpg 1_21.jpg 2_25.jpg 3_21.jpg

Edited by zamunda on 09/10/2021 10:26 AM
renatoa
Congrats !

Actually, the slew feature can be implemented human side, being careful to not move the Artisan slider in big steps. All you have to do is to refrain handling the fan slider with the mouse, is the only way to jump from 0 to 100% in a single step. With the keyboard, and up/down keys, the slider steps in small increments, even finer than the slew step from software solution.
With a bit of discipline, it could become a habit.
zamunda
Hello Renatoa,

Thanks for your reply and tip on using the keyboard, wasn't aware of this, tried it and is indeed very handy!

Another potential risk with modded popcorn machines is that if you leave the heater on for some reason without running the fan, after 5-10 seconds the coil burns the fan housing or worse. This happened to me once and I guess I am not the only oneGrin

Is there a way to prevent this? I thought of adding a condition in the void loop:

"if value from fan slider >50 {
start heater

} else {
...
}"

But I do not know whether this is good practice? Or are there other common solutions (besides from paying attention while roasting)?

Regards!
Edited by zamunda on 09/11/2021 10:38 AM
renatoa
Yep, this is the logic in TC4 too...

For any attempt to change heater level, the check below:


   if (FAN_DUTY < HTR_CUTOFF_FAN_VAL) {
      new_levelot1 = 0;
   }
   else {
      new_levelot1 = levelOT1;
   }


And reciprocal, when fan change attempt...


  if( pac_level < HTR_CUTOFF_FAN_VAL ) { // if new levelOT2 < cutoff value then turn off OT1
    output_level_icc( 0 );
 }
 else {  // turn OT1 back on again if levelOT2 is above cutoff value.
    output_level_icc( levelOT1 );   
zamunda
Hello Renatoa,

Thank you for this snippet, I rewrote my sketch like this based on that:


// Define minimal airflow setting
#define HTR_CUTOFF_FAN_VAL 50  // stop heater if airflow goes below this value

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

  if ( au16data[5] < HTR_CUTOFF_FAN_VAL ) { //set air to minimal value to avoid overheating
    analogWrite(fan, (HTR_CUTOFF_FAN_VAL / 100.0) * 255);
  }
  else {  // set new air value
    analogWrite(fan, (au16data[5] / 100.0) * 255);
  }

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

  if ( au16data[5] < HTR_CUTOFF_FAN_VAL ) { //stop heater to avoid overheating
    digitalWrite(relay, LOW);
    delay(500);
  }
  else {  // set new heater value
    // heater control:
    digitalWrite(relay, HIGH);
    delay(au16data[4] * 10);
    digitalWrite(relay, LOW);
    delay((100 - au16data[4]) * 10 - 1);
  }

}


Does this make sense?

Within TC, there is a var "FAN_DUTY" which holds the ACTUAL value of the fan, however, within my project, I do not know whether/how this value is stored or can be obtained from Artisan. I only know of the DESIRED value which is "au16data[5]".
Am I right here?

Thanks!
renatoa
Why are you operating changes on fan before the modbus poll and not after ?
This way you introduce one second delay between the slider change and fan speed change... without any benefit I can detect.
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