Skywalker, the AL... | [263] |
War on Farmers by... | [53] |
Green coffee reviews | [10] |
Help and recommen... | [10] |
Testing Arduino UNO with bitwisetech / popc and MAX6675
|
|
zamunda |
Posted on 08/10/2021 1:27 PM
|
![]() 1/4 Pounder ![]() Posts: 173 Joined: November 17, 2020 |
Quote zamunda wrote: [quote]@zamunda is possible to share motor shield and arduino connection on basic drawing. I have some doubts about the way I connected it (though it is working ![]() The fan is driven with a 18V DC power supply and so according the specs I have to remove the 12V jumper. However, if I do that, it does not work so I have to look into that. I found out how it works, jumper should be removed (since DC voltage >12V) but then board should be powered with a 5V from the Arduino (please see attached image). This should help/overcome burning the board in case of high current/voltage. Quote Besides, I use this board only for testing but I think this is a very old motor driver board and I doubt whether it can be used in a "production environment"... If anyone could advice on a better alternative (maybe the MD10C?) I would be gratefull! Having understood how this works and having made the adjustment, will give this board a chance and keep testing. Furthermore, if I can follow up Renatoa's suggestion how avoid big current draw (slew fan logic), it is worth trying. Regards,
zamunda attached the following image:
Edited by zamunda on 08/10/2021 1:36 PM |
|
|
miyankizu |
Posted on 08/11/2021 12:35 AM
|
![]() Newbie ![]() Posts: 10 Joined: August 10, 2021 |
@zamunda thank you again ![]() |
|
|
zamunda |
Posted on 08/11/2021 4:41 AM
|
![]() 1/4 Pounder ![]() Posts: 173 Joined: November 17, 2020 |
Quote renatoa wrote: current is a variable you keep in your sketch, not taken from Artisan. And target is the value from ModBis register 5, you guessed right, when slider from Artisan move, the new value will be sent via ModBus to you. The slew logic will compare the current fan speed value with new target, and, if different, will increase/decrease current variable value by slew step. The new current value will be sent to fan control circuit. Hello Renatoa, OK, thanks, I think I'll understand, try to work that out! Regards, Edited by renatoa on 08/11/2021 6:06 AM |
|
|
zamunda |
Posted on 08/11/2021 8:31 AM
|
![]() 1/4 Pounder ![]() Posts: 173 Joined: November 17, 2020 |
Hello Renatoa, Quote renatoa wrote: current is a variable you keep in your sketch, not taken from Artisan. And target is the value from ModBis register 5, you guessed right, when slider from Artisan move, the new value will be sent via ModBus to you. The slew logic will compare the current fan speed value with new target, and, if different, will increase/decrease current variable value by slew step. The new current value will be sent to fan control circuit. Studied the code for the TC4 and modified my sketch like this (see below). Does not seem to work though... Any suggestions? Thanks! Code Download source
Edited by zamunda on 08/11/2021 9:01 AM |
|
|
renatoa |
Posted on 08/11/2021 12:14 PM
|
![]() Administrator ![]() Posts: 3131 Joined: September 30, 2016 |
Well, the slew logic should not have been taken so literally from TC4, because there the slew routine is called very fast, every some milliseconds, while in your case the main loop take more than one second. So things are a lot simpler, without those last change checks, as I tried sketch below: Code Download source void slew_fan() { // limit fan speed increases Because speed changes are applied so slow, probably will be a good idea to change SLEW_STEP to 10, my guess. Please, give it a try and tell us how it works. |
|
|
zamunda |
Posted on 08/11/2021 1:54 PM
|
![]() 1/4 Pounder ![]() Posts: 173 Joined: November 17, 2020 |
Quote renatoa wrote: Well, the slew logic should not have been taken so literally from TC4, because there the slew routine is called very fast, every some milliseconds, while in your case the main loop take more than one second. So things are a lot simpler, without those last change checks, as I tried sketch below: Code Download source void slew_fan() { // limit fan speed increases Because speed changes are applied so slow, probably will be a good idea to change SLEW_STEP to 10, my guess. Please, give it a try and tell us how it works. Hello Renatoa, If I copy your code literally, I get: exit status 1 expected unqualified-id before 'else' So I guess it should be: Code Download source
Now it compiles, the code does initiate the fan after moving the slider but stays there at a very low level... I copy the complete sketch once again below, a big thanks as usual for any hint! Code Download source
|
|
|
renatoa |
Posted on 08/11/2021 2:12 PM
|
![]() Administrator ![]() Posts: 3131 Joined: September 30, 2016 |
Nope, below is right: 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 )); } 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 )); } } Forgt some extra } without the matching left brackets |
|
|
zamunda |
Posted on 08/11/2021 2:38 PM
|
![]() 1/4 Pounder ![]() Posts: 173 Joined: November 17, 2020 |
Quote renatoa wrote: Nope, below is right: 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 )); } 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 )); } } Forgt some extra } without the matching left brackets Thanks for your reply, I copied in your snippet, compiled and uploaded but still get the same behaviour: it seems to initiate but does not step up or step down, it hangs on an initial low level, fan does not even turn. I include the complete last code once again since there may be an error elsewhere or logic problem. Thanks! Code Download source
|
|
|
zamunda |
Posted on 08/12/2021 1:40 PM
|
![]() 1/4 Pounder ![]() Posts: 173 Joined: November 17, 2020 |
Hello, I think I found (part) of the problem why the slew()-function did not work as expected. Within the slew_fan the value for "current" should be updated after each cycle otherwise it stays at its initial value. So I added "current = current - delta;" and "current = current + delta;" respectively after the analogWrite for the fan. Now it steps to the desired target value! @renatoa: Still have some doubt whether the fan should have it's own delay value since it now depends on the delay of the heater at the end of the loop. Am I right here? Thanks in advance! Regards. Code Download source
Complete sketch: Code Download source #include <max6675.h> |
|
|
renatoa |
Posted on 08/12/2021 2:00 PM
|
![]() Administrator ![]() Posts: 3131 Joined: September 30, 2016 |
Good find, congrats ! To have different timings for heater and fan, the main loop should be rewritten with significant changes. A major point to rethink is the MAX library usage, which seems to be at least 250 ms of blocking code, that must be rewritten as async code, if you want total freedom. |
|
|
zamunda |
Posted on 08/13/2021 4:12 AM
|
![]() 1/4 Pounder ![]() Posts: 173 Joined: November 17, 2020 |
Hello Renatoa, Thanks for your reply on the timings! Quote renatoa wrote: To have different timings for heater and fan, the main loop should be rewritten with significant changes. A major point to rethink is the MAX library usage, which seems to be at least 250 ms of blocking code, that must be rewritten as async code, if you want total freedom. Based on what you state above, I made the following adjustments to the sketch...have to test it later but I would like to share the idea already. Does this make sense? Big thanks as usual. Code Download source #include <max6675.h> Reference: https://www.programmingelectronics.com/arduino-millis-multiple-things/ |
|
|
zamunda |
Posted on 08/15/2021 1:22 PM
|
![]() 1/4 Pounder ![]() Posts: 173 Joined: November 17, 2020 |
Quote renatoa wrote: 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: Code Download source // heater control loop: with... Code Download source digitalWrite(relay, HIGH); This change should give you full 0-100% range control, and not dependent on mains frequency. Today I did some real roasting with the MODBUS setup where I controlled the heater from a Artisan slider and manual control for the fan. It went well though I noticed that when I set at a certain stage the heater to "100" temperature dropped severely during several seconds, once I set it to "90", temperature came back to normal. When doing "dry-testing" of this setup with only a SSR and a fan connected to the Arduino, I also noticed that as soon I set the "heater" to 100, the fan stopped all of a sudden. Looking at the heater-timing, I think the problem is caused by the value of "delay((100 - au16data[4]) * 10 - 1)", this becomes negative if slider (that is, value of au16data[4]) is set to 100. What I understand, this may result in very long delays. So I changed this line to: delay((100 - au16data[4]) * 10 + 1); As a result, this delay is 1 millisecond when slider is set to 100. I tested it and at least the fan stays on when I set heater slider to "100". Is this a correct assumption and solution? Please let me know. Regards, Code Download source void loop() { |
|
|
zamunda |
Posted on 08/19/2021 12:48 PM
|
![]() 1/4 Pounder ![]() Posts: 173 Joined: November 17, 2020 |
Hello, I am now ready to connect to the Arduino Board by BT, have the HC-06, from my Mac I can see the connection and can connect after putting the default pw (1234). But once connected it does not accept to upload my sketch from Arduino. Arduino is powered with a 1A adapter from my iPhone. Do I miss something there? From Artisan, I can configure the port to /dev/tty.HC-06-DevB/ but can not confirm that this works since I have no probe connected to the board yet. I was wondering if there is something else needed to set up a succesfull connection from Mac/Artisan to the Arduino UNO? Thanks in advance for any advice! Regards Edited by zamunda on 08/19/2021 12:58 PM |
|
|
renatoa |
Posted on 08/19/2021 2:46 PM
|
![]() Administrator ![]() Posts: 3131 Joined: September 30, 2016 |
You can't use the same serial comm port for both BT and USB. Some switching is required, at least one of the lines. |
|
|
zamunda |
Posted on 08/20/2021 2:19 AM
|
![]() 1/4 Pounder ![]() Posts: 173 Joined: November 17, 2020 |
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 |
Posted on 08/20/2021 11:47 AM
|
![]() 1/4 Pounder ![]() Posts: 173 Joined: November 17, 2020 |
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 |
Posted on 08/20/2021 11:50 AM
|
![]() 1/4 Pounder ![]() Posts: 173 Joined: November 17, 2020 |
Pic of BT model
zamunda attached the following image:
|
|
|
zamunda |
Posted on 08/21/2021 5:13 AM
|
![]() 1/4 Pounder ![]() Posts: 173 Joined: November 17, 2020 |
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 |
Posted on 08/21/2021 6:55 AM
|
![]() Administrator ![]() Posts: 3131 Joined: September 30, 2016 |
Is the BT speed in Artisan the same as for usb ? |
|
|
zamunda |
Posted on 08/21/2021 7:14 AM
|
![]() 1/4 Pounder ![]() Posts: 173 Joined: November 17, 2020 |
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:
Edited by zamunda on 08/21/2021 8:00 AM |
|
|
renatoa |
Posted on 08/21/2021 8:22 AM
|
![]() Administrator ![]() Posts: 3131 Joined: September 30, 2016 |
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 |
Posted on 08/21/2021 8:44 AM
|
![]() 1/4 Pounder ![]() Posts: 173 Joined: November 17, 2020 |
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 |
Posted on 08/21/2021 11:54 AM
|
![]() Administrator ![]() Posts: 3131 Joined: September 30, 2016 |
And the same dialog for modbus over usb connection ? |
|
|
zamunda |
Posted on 08/21/2021 12:10 PM
|
![]() 1/4 Pounder ![]() Posts: 173 Joined: November 17, 2020 |
Quote 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:
|
|
|
zamunda |
Posted on 08/23/2021 4:06 AM
|
![]() 1/4 Pounder ![]() Posts: 173 Joined: November 17, 2020 |
Quote zamunda wrote: Quote 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! |
|
Jump to Forum: |