Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dasaki committed Nov 9, 2019
1 parent 5e6d998 commit 8e25845
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
7 changes: 4 additions & 3 deletions ReflowController/ReflowController.ino
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ uint8_t zxLoopDelay = 0;

// calibrate zero crossing: how many timerIsr happen within one zero crossing
#define zxCalibrationLoops 128
#define zxPerSecCalibrationTime 4000
#define zxPerSecCalibrationTime 2000

struct {
volatile uint8_t iterations;
Expand Down Expand Up @@ -636,7 +636,6 @@ void loop(void)
PID.SetControllerDirection(REVERSE);
PID.SetTunings(fanPID.Kp, fanPID.Ki, fanPID.Kd);
Setpoint = idleTemp;

}

if (Input < (idleTemp + 5)) {
Expand All @@ -660,7 +659,9 @@ void loop(void)
// PIDTune.setpoint = 210.0; // is private inside PIDTune

if (val != 0) {
currentState = CoolDown;
toggleAutoTune();
Setpoint = idleTemp;
Output = 0;
}

if (currentState != Tune) { // we're done, set the tuning parameters
Expand Down
8 changes: 5 additions & 3 deletions ReflowController/UI.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void displaySplash() {
// splash screen
tft.setCursor(2, 30);
tft.setTextSize(2);
tft.print("Reflow");
tft.print("nanoReflow");
tft.setCursor(tft.width()-120, 48);
tft.print("Controller");
tft.setTextSize(1);
Expand Down Expand Up @@ -745,12 +745,14 @@ void updateProcessDisplay() {
alignRightPrefix((int)heaterValue);
tft.print((int)heaterValue);
tft.print('%');

#ifdef WITH_FAN
tft.print(" \x2a");
alignRightPrefix((int)fanValue);
tft.print((int)fanValue);
tft.print('%');

#else
tft.print(" ");
#endif
tft.print(" \x12 "); // alternative: \x7f
printDouble(rampRate);
tft.print("\367C/s ");
Expand Down
4 changes: 2 additions & 2 deletions ReflowController/config.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef CONFIG_H
#define CONFIG_H

//#define ALWAYS_FIRST_RUN
//#define ALWAYS_FIRST_RUN // force resett to factory settings at startup
//#define FAKE_HW 1
#define PIDTUNE 1 // autotune wouldn't fit in the 28k available on my arduino pro micro.
//#define PIDTUNE 1 // autotune wouldn't fit in the 28k available on my arduino pro micro.
#define WITH_BEEPER // Enables Beeper
//#define WITH_FAN // Enables Lid opening Servo (not yet implemented)
//#define WITH_SERVO // Enables Lid opening Servo (not yet implemented)
Expand Down

34 comments on commit 8e25845

@AABatteries
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any chance you will shortly describe new release notes? I'm running the v3.2 release with good results, eager to see what you came up with this time! Did you fix the timebase issues that multiple people have described?

@dasaki
Copy link
Owner

@dasaki dasaki commented on 8e25845 Nov 9, 2019 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@avolex
Copy link

@avolex avolex commented on 8e25845 Dec 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no idea how to work with github, and fail to get all libraries

@dasaki
Copy link
Owner

@dasaki dasaki commented on 8e25845 Dec 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no idea how to work with github, and fail to get all libraries

https://stackoverflow.com/questions/3796927/how-to-git-clone-including-submodules

@avolex
Copy link

@avolex avolex commented on 8e25845 Dec 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks for that (will study that). however got the necessary libraries and got it compiled. all working (still awaiting MAX6675). noticed however frequency pops up as 25Hz??

@dasaki
Copy link
Owner

@dasaki dasaki commented on 8e25845 Dec 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks for that (will study that). however got the necessary libraries and got it compiled. all working (still awaiting MAX6675). noticed however frequency pops up as 25Hz??

Strange, should be either 50Hz or 60Hz. Have a look if you see some bug. Other users have also reported issues with the frequency ( which drives all the timings ).

@avolex
Copy link

@avolex avolex commented on 8e25845 Dec 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Silly me.... used a H11AX type optocoupler which has no anti parallel emitter diodes. will have to order H11AA type and MAX6675 to finish. will let you know outcome.

@avolex
Copy link

@avolex avolex commented on 8e25845 Jan 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, Have received the MAX6675 (not the H11AX yet) but seems that I can not get the code compiled to get the Thermocouple working. I have done some checks and know the wiring and hardware are OK. it must be in the way I compile (although it passes all compiling and uploads)

@dasaki
Copy link
Owner

@dasaki dasaki commented on 8e25845 Jan 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@avolex no idea why the thermocouple is not working for you. Please test the serial output it with this example code MAX6675-library/examples/serialthermocouple/serialthermocouple.pde

making this changes:

int thermoDO = 12;
int thermoCS = A1;
int thermoCLK = 13;

@avolex
Copy link

@avolex avolex commented on 8e25845 Jan 15, 2021 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dasaki
Copy link
Owner

@dasaki dasaki commented on 8e25845 Jan 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@avolex
So I would just wait for the H11AA. The code ( mostly developed by Ed Simmons for his commercial reflow controller, www.estechnical.co.uk ) is very dependant on the cross detection.

@avolex
Copy link

@avolex avolex commented on 8e25845 Jan 16, 2021 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@avolex
Copy link

@avolex avolex commented on 8e25845 Mar 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi David,
After a long wait finally received the H11AA. When installed, the temperature was shown properly.
So this maybe a hint to other people having this issue about no temperature reading, use the proper Opto-Coupler with the two opposed parallel LED diodes.

The only issue I still have is the Mains shows as 25Hz while it should be 50Hz.
I have tried the ticksPerSec =0 change to 100, TICKS_PER_UPDATE = 25 to 50 but that did not work.
However, I will now check weather I can make it to reflow as it is intended with this (hopefully) minor flaw.

Best Regards avolex

@dasaki
Copy link
Owner

@dasaki dasaki commented on 8e25845 Mar 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi David,
After a long wait finally received the H11AA. When installed, the temperature was shown properly.
So this maybe a hint to other people having this issue about no temperature reading, use the proper Opto-Coupler with the two opposed parallel LED diodes.

The only issue I still have is the Mains shows as 25Hz while it should be 50Hz.
I have tried the ticksPerSec =0 change to 100, TICKS_PER_UPDATE = 25 to 50 but that did not work.
However, I will now check weather I can make it to reflow as it is intended with this (hopefully) minor flaw.

Best Regards avolex

Hmmm, ticksPerSec is the number of zero crossings per second, and is what determines the mains frequency, and also all the timings. You can try changing this (line 350 of ReflowController.ino):

ticksPerSec = round(1000*zxTicksCalibration/(float)zxPerSecCalibrationTime);

for this:

ticksPerSec = round(2000*zxTicksCalibration/(float)zxPerSecCalibrationTime);

@avolex
Copy link

@avolex avolex commented on 8e25845 Mar 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi David, Many thanks for you support.

That did the trick for the 50Hz indications. that is shown correct now.
However I found out that I have another issue, in that iot does not follow the reflow curve, but keeps heating.
My problem is that I can not compile correctly.
if I have ReflowController.INO with #include <MAX6675.h> and in temperature.h MAX6675 thermocouple(PIN_TC_CS), it does compile.
but with #include "max6675.h" and MAX6675 thermocouple(PIN_TC_CLK, PIN_TC_CS, PIN_TC_DO) Which it actually should be, I can not compile it.
I probably have some library issues, but the double quotes dictate the "max6675.h" file is used loacclly and seems to be the Ladyada library(?)

This is the error

In file included from C:\Users\avolex\Desktop\nanoReflowController-3.3 works1\nanoReflowController-3.3\ReflowController\ReflowController.ino:32:0:
C:\Users\avolex\AppData\Local\Temp\arduino_build_317624\sketch\temperature.h: In function 'void readThermocouple()':
temperature.h:24:32: error: 'class MAX6675' has no member named 'readTempC'
float reading = thermocouple.readTempC(); //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
^~~~~~~~~
exit status 1
'class MAX6675' has no member named 'readTempC'

@dasaki
Copy link
Owner

@dasaki dasaki commented on 8e25845 Mar 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@avolex well, I just downloaded all the required libraries (https://github.com/dasaki/nanoReflowController/tree/master/libraries) and the unmodified code and it compiles right.

Did you use the suggested library? https://github.com/adafruit/MAX6675-library/tree/eb73fa019502dd239d093c6885af5dad7395b533

@avolex
Copy link

@avolex avolex commented on 8e25845 Mar 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi David,

Sorry to bother you, and taking up your time.

I now have downloaded the files again, and have the files structure as follows:
Directory of C:\Users\avolex\Desktop\test\ReflowController

06 Mar 2021 11:37

.
06 Mar 2021 11:37 ..
06 Mar 2021 11:27 3.314 config.h
06 Mar 2021 11:57 0 dir.txt
04 Mar 2021 13:19 1.825 eepromHelpers.h
04 Mar 2021 13:19 2.039 globalDefs.h
04 Mar 2021 13:19 4.174 helpers.h
06 Mar 2021 10:41 libraries
06 Mar 2021 11:29 3.273 PDQ_ST7735_config.h
04 Mar 2021 13:19 1.002 portMacros.h
06 Mar 2021 11:26 23.099 ReflowController.ino
06 Mar 2021 11:09 753 temperature.h
04 Mar 2021 13:19 22.237 UI.h
10 File(s) 61.716 bytes

Directory of C:\Users\avolex\Desktop\test\ReflowController\libraries

06 Mar 2021 10:41

.
06 Mar 2021 10:41 ..
05 Mar 2021 12:14 encoder
06 Mar 2021 10:43 MAX6675
05 Mar 2021 12:14 menu
05 Mar 2021 12:14 PDQ_GFX_Libs
05 Mar 2021 12:14 PID_AutoTune_v0
05 Mar 2021 12:14 TimerOne
0 File(s) 0 bytes

also made sure the libraries here are also in the C:\Users\avolex\Documents\Arduino\libraries
and I do not know why, but when it compiles it also goes to the Program Files(x86) libraries, so added the files there as well.

when compiled the Temp shows 0, and the plot of the red line exactly shows a profile, but blue line is a flat line.
(if red is my heater plot, how can it do that wile temp shows 0)

when I pull in the max6675.h file up from the libraries DIR to the ReflowController directory and do a compile, it will not compile:
Error compiling for board Arduino Pro or Pro Mini.
with following errors:
Error compiling for board Arduino Pro or Pro Mini.
C:\Users\avolex\AppData\Local\Temp\cc0h1M6T.ltrans0.ltrans.o: In function readThermocouple()': C:\Users\avolex\AppData\Local\Temp\arduino_build_584145\sketch/temperature.h:19: undefined reference to MAX6675::readCelsius()'
C:\Users\avolex\AppData\Local\Temp\cc0h1M6T.ltrans0.ltrans.o: In function global constructors keyed to 65535_0_ReflowController.ino.cpp.o.2590': <artificial>:(.text.startup+0xaa): undefined reference to MAX6675::MAX6675(signed char, signed char, signed char)'
collect2.exe: error: ld returned 1 exit status

I understand that it must be a compiling issue, but do not see where it goes wrong.

@avolex
Copy link

@avolex avolex commented on 8e25845 Mar 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some additional try outs....
Have done as someone suggested before on the random lab, I disabled in ReflowController > // setupTFT();//, and switched on Serial coms.
And then I see the temperature in the serial monitor, and even see the plot when I use the Serial Plotter utility.
Regards

@dasaki
Copy link
Owner

@dasaki dasaki commented on 8e25845 Mar 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you are using an Arduino Pro or Pro Mini. I hope it is not a 3.3v/8MHz one.
If you have installed the MAX6675 library via the library manager try this:
Uninstall it, then donwload and manually install the library from the link: https://github.com/adafruit/MAX6675-library/tree/eb73fa019502dd239d093c6885af5dad7395b533

@avolex
Copy link

@avolex avolex commented on 8e25845 Mar 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed it is a Pro-Pro mini but a 5V version.
I did already get that library, and placed that inside the windows/Programs(86)/Arduino library as well as in the my-document/Arduino library, and in the ReflowContrtoller working folder.
I do notice however, that even when an #include file has the quote marks ("") it still goes to the above mentioned directories I am using Arduino IDE 1.8.13
(not sure if this 1.8.13 IDE has the arduino/Arduino#5186)

If the ReflowController (non functioning at moment) is running I see on my Oscilloscope the clock to the MAX6675 is a very dirty signal, and there is no data at all coming from the MAX6675. The MAX6675 clock almost looks like sine wave at almost 8Mhz(132nSec). When I load the MAX6675 example it is of course much slower but shows nice signals from the MAX6675

For my feeling, the signal towards the sensor is way to fast. This also may be why the starup frequency and loop-delay are wildly different at each startup.
It also may be the cause of when I start the profile, the RED temperature line(supposed to be the MAX6675) indication ramps up appears to follow the plot, and the BLUE(profile) stays as flat line on 0deg but the Halogen lamp is at 100% all the time. It appears to me all is running too fast, but see no way where to slow the program down for the temperature sensing.
(what I did try is in temperature.h to replace the digitalHigh/Low with digitalWrites which are slower, but that did not do the trick)

@dasaki
Copy link
Owner

@dasaki dasaki commented on 8e25845 Mar 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"as well as in the my-document/Arduino library, and in the ReflowContrtoller working folder"

Don't dupliocate libraries!!!
Put it only in the my-document/Arduino/library folder.

There must be some difference between my hardware/software and yours. You shouldnt need to modify the code at all. My mains frequency is also 50Hz and I have no problem at all with the original unmodified code/libraries. Please recheck all your setup thoroughly.

@avolex
Copy link

@avolex avolex commented on 8e25845 Mar 9, 2021 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dasaki
Copy link
Owner

@dasaki dasaki commented on 8e25845 Mar 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you wiring the max6675 to the correct pins?

static const uint8_t PIN_TC_CS = A1;
static const uint8_t PIN_TC_DO = 12;
static const uint8_t PIN_TC_CLK = 13;

@avolex
Copy link

@avolex avolex commented on 8e25845 Mar 9, 2021 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dasaki
Copy link
Owner

@dasaki dasaki commented on 8e25845 Mar 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks to me that the MAX6675 , ST775S are both active at the same time. The CS (chip select) lines shoud allow only one of them to be active at the same time. PIN_LCD_CS activates the ST775S, and the PIN_TC_CS activates the MAX6675. In my code I use ST7735_INITR_REDTAB.

@avolex
Copy link

@avolex avolex commented on 8e25845 Mar 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately no this is not the case (otherwise the display indication would be garbled), I have checked with the oscilloscope, and there are separated by 1.2mSec.
(Noting that the CS for the MAX is 1.68mSec, and the MAX readouts occur every 250mSec and TFT CS burst of updates are every 500mSec, as to be expected.)
When I do get temperature readings with the changes I enter and SPI library I mentioned before, I would expect that the PID loop would keep control of the temperature.

I do realize that not getting it to work here is completely my fault here, in handling of library's.
However I downloaded all needed library's from the GITHUB

At this moment I am going to cleanup my machine from Arduino completely but saving all folders on separate backup disk, and reinstall Arduino IDE from scratch.
(this will come back to haunt me for all my old projects probably :-( me thinks)

Will let you know the outcome

@avolex
Copy link

@avolex avolex commented on 8e25845 Mar 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new update :
Having wiped out all evidence of Arduino IDE on my PC here, reinstalled it, finding the newly created library directory in my-documents empty, it was easy to put your required libraries in. Except for complaining first time about PID-v1 not there (which in Github shows reverted) after which I got that included.
After compiling/linking/uploading it it still does not work.

Then moved on to shorten the wires to my MAX and TFT to rule out long wiring issues, to no avail.

so....it still does not shows the temperature

Hoping not to infringe and being rude by asking if it would be possible to have the build .hex file from you to give that a try to load into my Arduino to check out all works with that? I will not give up then as I would like to get it to properly compile here for myself, and finding out my problems.

@dasaki
Copy link
Owner

@dasaki dasaki commented on 8e25845 Mar 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@avolex
Copy link

@avolex avolex commented on 8e25845 Mar 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for that, tried it and worked like a charm. Now shows Temp and follows profile.
Proving with this that the hardware is all OK, but the fault is in my compiling.
I will now concentrate on getting it properly compiled myself, and if successful and and there is some learning experience then I will come back and share for others who may run in to the same issue like me.

Once again,
many thanks, you saved the day.

@dasaki
Copy link
Owner

@dasaki dasaki commented on 8e25845 Mar 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm glad it helped!
For you records, it was compiled with the option "Arduino Uno" as board.
The code was the original, no modifications. Did it correctly detect the mains frequency?

@avolex
Copy link

@avolex avolex commented on 8e25845 Mar 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loop-delay=40, Frequency=50. Spot on.
Loaded it in the Nano Pro 5V 328 16Mhz first with Xloader and later with the AVR programming string as captured from Arduino IDE

@dasaki
Copy link
Owner

@dasaki dasaki commented on 8e25845 Mar 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok then. Let me know once you find the solution.

Regards,

David.

@avolex
Copy link

@avolex avolex commented on 8e25845 Mar 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do for sure, But maybe going at a bit slower pace. But for sure want to be able to compile myself. :-)

@avolex
Copy link

@avolex avolex commented on 8e25845 Mar 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not expect that I would get this far so soon, But got it compiling with a bunch of warnings from the ClickEncoder.
But all appears to work. Temperatures works, TFT is good, and encoder works, and when started it follows the profile nicely

What I did was downloading the Libraries you mentioned from Github as ZIP files then added them with adding ZIP library function in the Arduino IDE, except for the PID_v1 which I manually downloaded the files created the folder and zipped it, then added it also.
(before I cloned the libraries in my GitHub Desktop and put the in the Library folder)

I have no idea if you have these warnings as well during compile from the ClickEncoder? (is it something I can ignore as it is just warnings and not errors?)

Please sign in to comment.