Skip to content

Advanced Command Interface and functional improvments #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

radensb
Copy link

@radensb radensb commented Mar 24, 2018

I have added an advanced, binary serial command interface that incorporates CRC validation to support an EEprofile definition over UART feature. This is because the command to set an EE profile requires a relatively large amount of data to be sent and written to the EEPROM, thus verifying it is correct is important. Also included is an Operational Mode feature that allows users to select a reflow control mode via the standard serial interface.

Advanced Serial Command Interface:
The interface is designed for software tool usage that communicates with the oven via CRC verified binary commands. The format is defined as (in hex):
FF 55 <SIZE> <HCRC> <D1> <D2>...<Dn> <DCRC>
Every entry is a byte. The first 4 bytes are the command header which easily fits in the UART hardware FIFO. It instructs the logic on how many bytes need to be buffered to process the advanced command (max of 255 bytes) and where the the Data CRC (DCRC) is. The SIZE is verified by the HCRC before continuing. Once the required amount of data is received, it is verified with the DCRC. If valid, the command is executed.

Currently, I have only implemented one command that uses this interface. The command is designed to update the CUSTOM#1 and CUSTOM#2 profiles in the EEPROM. The format is:
FF 55 62 4A EE <PROFILE> <Dh> <Dl> ... <DCRC>
where,

  • 0xFF and 0x55 are sync bytes
  • 0x62 is the SIZE
  • 0x4A is the HCRC defined as (0x100 - (sum_of_header_bytes & 0xFF))
  • 0xEE is the binary command for an EEprofile definition
  • <PROFILE> is the custom profile number (0x01 or 0x02)
  • <Dh> is the high byte of a profile temp point
  • <Dl> is the low byte of a profile temp point
  • <DCRC> is (0x100 - (sum_of_all_the_non_header_bytes & 0xFF))

The EEprofile command expects 48 temperatures to define a profile (or 96 bytes as each temperature is represented at an unsigned 16-bit value).
EX:
FF 55 62 4A EE 02 00 32 00 32 00 32 00 3C 00 49 00 56 00 64 00 71 00 7E 00 8C 00 8F 00 93 00 96 00 9A 00 9D 00 A1 00 A4 00 A8 00 AB 00 AF 00 B3 00 B7 00 C3 00 CF 00 D7 00 CF 00 C3 00 B7 00 A8 00 9A 00 8C 00 7D 00 6F 00 61 00 52 00 44 00 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 87

Some optimizations needed to be made with regards to ISR handling and availability to handle the length of this command properly.

Operational Modes:
There are three operational modes that are available and an operation mode temperature threshold setting that can be chosen via the standard serial interface.

  1. AMBIENT
  2. MAXTEMPOVERRIDE
  3. SPLIT
  • Ambient mode is the standard air temp average from the thermocouples hanging in the heat chamber used as control.
  • MAXTEMPOVERRIDE is a mode previously available as a compile time option to override the ambient average based on a thermocouple that is 5 degrees over the average as the control. This threshold is now definable via the serial interface.
  • SPLIT is a new mode that uses the ambient temperature to control the oven until the threshold is reached, then it uses one of the extra thermocouples (or the average of both if they are both present) to control the oven.

Both the operating mode and threshold values are stored in the EEPROM and loaded on power up so they don't need to be set every time. The Help menu has been updated to reflect the new standard interface commands that control these settings.

Using the SPLIT mode has yielded great results in my tests. I set the threshold to 65C and used two identical boards on each side of the drawer.
leadprofile_middle

As can be seen from the above example test, the ambient temperature is used until the threshold of 65 was reached, then it shifts to the average temp of my extra thermocouples and controls based on that. As a result, the surface of the PCB follows the profile very well, with the expected thermal lag. The red line is the average temp (the control) and the blue and orange are the PCB surface temperatures. The yellow circle highlights the transition from ambient control to PCB surface control.
leadprofile_middle_zoom

radensb added 2 commits March 23, 2018 20:22
Added advancedcmd.c and advancedcmd.h.

circbuffer.c:
- Added circ_buf_flush(), circ_buf_peek(), and circ_buf_getAddr().

main.c:
- Added advanced command interface and OpMode/OpThresh commands.

nvstorage.h:
- Modified eNVItem emun to include OP_MODE and MODE_THRESH.

onewire.c:
- Tighter focus on interrupt disable to prevent UART loss.

sensor.c:
- Added OpMode and OpModeThreshold features.

sensor.h:
- created new type OperationMode_t to define OpMode.

serial.c:
- Added uart_available(), uart_rxflush(), uart_chkAdvCmd().
- Modified ISR to empty UART Rx FIFO when called instead of pulling out one byte per call.
@taliesin
Copy link

taliesin commented Apr 2, 2018

As nobody seems to care ...

I actually don't see the point in implementing a binary protocol on top of the serial interface:

  • only storing profiles to the EEPROM needs more than a few bytes to be transported
  • this is done quite rarely (as I would guess)
  • the communication could even use 9600Bd and be fast enough for this amount of data and reduce the requirements for real-time dramatically
  • data disturbance is pretty improbable (unless your oven is located 15m away from your computer)
  • with your implementation, there is still no simple method to use a normal terminal program for it (need to send a full line of data, and even that is not safe (depends on buffer sizes)!).

I just took over your improvements concerning the interrupt latencies in onewire.c and serial.c into my branch, thanks. You should have split these changes to separate commits (sorry I seem to be in criticizing mode ;-) ).

@xnk
Copy link
Member

xnk commented Apr 16, 2018

I agree that a text-based protocol will be more than fast enough, but uploading custom profiles is very handy. If there's no interest of being backwards compatible with the shipping firmware then the profiles can be much more compact as well (only a ramp time and setpoint, then repeat)

@taliesin
Copy link

My current version may upload up to 4 custom profiles, I'm using 1byte values to represent temperature between 20 and 275°C. I'd like to stick with this kind of profile representation, because otherwise the edit via keyboard makes no sense any more.
However the 'save' command is currently not very forgiving, next to no error checking.
I think the interest in backward compatibility is long gone, can't imagine anyone to want to go back to the original SW.

@radensb
Copy link
Author

radensb commented Apr 16, 2018

I agree that the text based protocol was more than adequate for the commands that were originally defined (almost all were 16 bytes or less). The motivation behind having a binary based protocol was to combat the data loss when sending a long command. I initially created a command following the sscanf() method with 48 %d variables to be filled. It worked about 20% of the time because of data loss. I figured that if the data was sent in binary with a tad of overhead, incomplete transfers could be detected and the tool sending the command could resend or something.

Then... I focused on the cause of the data loss and discovered that the serial ISR and onewire code needed to be optimized and that was where bytes were getting dropped. Once I completed those changes, I never experienced data loss making the binary protocol a bit unnecessary. But, I still liked the CRC protection feature (especially for data transfer commands) and figured I would submit it in case others saw potential in it and had ideas of other commands that could benefit. It was intended to complement the already existing text based protocol.

@taliesin
Copy link

BTW I optimized the serial driver further. Using the IIR bits may not be reliable, it may hide potential transmit fifo interrupts if the receive buffer is full. The Linux driver for the 16550 has the same rational (I looked it up after reading that the UART is actually 16550 register compatible) and uses LSR instead.

@Bibbbi
Copy link

Bibbbi commented Dec 30, 2018

@radensb
What is Reflow Controller for a Application? Is it Open Source or Freeware?

@taliesin
Copy link

taliesin commented Jan 1, 2019

Although not addressed, please read the LICENSE file, in short it's GNU version 3 and obviously it's open source, you are sitting right in front of it.

@Bibbbi
Copy link

Bibbbi commented Jan 1, 2019

Soory, i mean this Windows Application:

reflow controller

@radensb
Copy link
Author

radensb commented Jan 3, 2019

I believe this is the GitHub repo for that project.
https://github.com/duncanellison/Reflow-Controller-T-962-
It was a side project for this oven from another member using the existing serial communication protocol. He supplied it as a jumping off point but does not support it. It would be awesome if it could be developed further as it is very convenient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants