-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Support for Flashforge Creator Pro2 #6553
base: master
Are you sure you want to change the base?
Conversation
eazrael
commented
Apr 7, 2024
- Basic configuration for an unmodded Flashforge Creator Pro2 (FFCP2) IDEX printer.
- Firmware and Klippy driver for Texas Instruments ADS1118 ADC chip. Required by FFCP2. Probably too uncommon for a standalone PR.
Are you reading the cold junction temperature from the ADS1118 and using that to compute the actual temperature? The chip should be located close to where the thermocouple cable connects to the PC board, so the internal temperature of the ADS1118 should be very close to the cold junction temperature. It looks like you are assuming the CJ temperature is always 25c? |
There's a lengthy comment in the code:
How did you solve this? I will look into your code in the next days when I find time. |
The mcu code reports back the cold junction temp and the mv reading of either channel 0 or 1. The cj temp is converted to a mv reading, added to the thermocouple mv and then converted back to a temperature. This is done in python starting at line 84 https://github.com/dockterj/klipper/blob/master/klippy/extras/ads1118_thermocouple.py This TI application note is a good reference https://www.ti.com/lit/ug/slau509/slau509.pdf?ts=1712687318583&ref_url=https%253A%252F%252Fwww.bing.com%252F Looking at your config file I suspect you could use my code as is. The makerbots use software spi, but the spi communication is handled by generic klipper code so your hardware spi config should work fine. |
Oh, i did not find this. I read the Datasheed section and SLAU509 and sbaa274a from TI. So for the FFCP2 this does not work, and usually when in doubt I make such things configurable, but then you need also an option for setting the ADC temperature as baseline or some override and then you have a configuration monster. |
I'm only guessing based on a picture of the main board I found online, but it looks like the ADC is located close to where the thermocouple connects, so the internal temperature of the ADC should be very close to the temperature of the cold junctions. Certainly they should reach an equilibrium where they are close to each other unless there is a major heat source somewhere near them. Is the ADC reading exactly 0? I'll try your code on my printer and see what it looks like. |
The thermocouples sit in the hotends, connected via PCB traces and simple cables to the Mainboard. Unless I total misunderstood thermocouples, the cold junctions is just outside of the extruder and before the PCB in the extruder. So you need the temperature there, but there is no sensors. The FFCP2 is enclosed you have there 40-60°C , So the cold junction is hotter that the ADS1118. I did it by the book and the results weren't feasible at least in the temperature range I could test them reliably (-20°C - 60°C). |
Weird design then. Any change there is a thermistor on the PCB where the thermocouple terminates? Without a way to measure the temperature there I don't see any way to make it accurate enough to use. |
Unfortunately no :-( As I did not expect that the ADS1118 is used elsewhere I just set it at 25°C for the temperature calculation. I will change that back to the ADC temp adjustment. |
https://evilazrael.net/tmp/temps_at_25_fixed.jpg 1 sek between them. I doubt that you can get a reliable temperature. |
If they are really using simple cables then you will never get a proper reading and it would explain your finger test. If the cold junction is between the "normal cable" and the alloy cables, then you are probably measuring just "something". Seems especially catastrophic, since this printer is fully enclosed. |
Sorry for the thermocouple discussion. Have never seen thermocouples before this project. When I made my "finger test", the thermocouple was directly connected to the mainboard, without the extruder PCB and the long cables between them, which also carry heating & extruder power lines. And I doubt they have alumel/chromel PCB traces and cables. So there was only 20cm between them, but it still showed that the ADC is probably not a reliable cold-junction. And will probably never be as the temperature range of the ADC is neglectible when compared to the thermocouples (generally speaking). I need to do some calculations, check what the error in the usual extruder temperature range is and how to how to fix that for the FFCP2. |
Basically, it is quite simple:
Personally, I think this type of sensor is a poor fit for 3D printing:
|
I did a couple of tests, Without any modification the ADC temperature is the closest you can get to the cold junction temperature in the FFCP2. |
Thank you for your contribution to Klipper. Unfortunately, a reviewer has not assigned themselves to this GitHub Pull Request. All Pull Requests are reviewed before merging, and a reviewer will need to volunteer. Further information is available at: https://www.klipper3d.org/CONTRIBUTING.html There are some steps that you can take now:
Unfortunately, if a reviewer does not assign themselves to this GitHub Pull Request then it will be automatically closed. If this happens, then it is a good idea to move further discussion to the Klipper Discourse server. Reviewers can reach out on that forum to let you know if they are interested and when they are available. Best regards, PS: I'm just an automated script, not a human being. |
Thanks. For what it is worth, I'm not familiar with the flashforge hardware and I didn't really understand the conversation leading up to this. I did look briefly through the code though, and it seems this code is invoking the spi transfer functions from irq context - that is not valid. Could you take a look at PR #6584 and the coding approach taken there? What advantages/disadvantages are there to the approach here? -Kevin |
Cutting the discussion above short: The FFCP2 cannot measure the extruder temperature correctly. The ADS1018 & ADS1118 (ADS1X18) are the SPI variants of their ADS1X1X siblings with a simple SPI wire protocol, you send 16bits of configuration and receive 16bits with the last reading at the same time. That's all. Not so generic as reading I2C registers. The ADS1118 is a 16bit ADC and the ADS1018 a faster 12bit ADC, which could be supported with adding two shifts of the reading values. And their next line of TI's SPI ADC chip has another protocol, so that's really something special. Scanning through #6584 code, one big difference is that Konstantin put all the configuration values as constants in the Python module, while I just put them in the configuration file, you have to look up in the data sheet that the setting "ads1118_pga: 7" means +-.256V. I tried to make the sensor available as a virtual pin by looking at the other modules, but failed. It ended up as new sensor type :-. Any short example or hint how to decouple the transfer from the interrupt (timer I assume)? |
Thanks. At a high-level though, #6584 seems to just add python code. Even if the ads1118 can't share any code, is it feasible to implement it with just Python code?
Ah, okay. What went wrong?
One would wake a "task" to perform the spi actions. Take a look at src/thermocouple.c for an example. For what it is worth though, I'd be reluctant to take on the long-term maintenance costs of new mcu code for one relatively uncommon printer that can't accurately measure temperatures even with that code.. -Kevin |
Not for me. See next response
To be honest, lack of documentation and defined interfaces of the core framework. Deducing everything from existing code in many variations is quite tedious. Even after tracing through a lot code I do not think I have understood the effects of "REPORT_TIME" correctly. And I have no problem with reading through code while looking for something you can use, extend, reuse, take as a template and so on. I hope I did not offend you.
Ah, I see. The connection between thermocouple_wake and thermocouple_task is outside of the module. Could fix that.
I can understand this, same consideration on my side. There also other printers using the ADS1118. Maybe @dockterj can start a new PR for his implementation. |
The REPORT_TIME is used to notify the heater code of how frequently it should expect a sensor update. It's used to setup the corresponding PWM timing for a heater. Basically, it's the time between each sensor report.
No offence taken. It's difficult with any large open-source project with so many different moving parts. There also doesn't seem to be a good example. The closest example I can think of would be src/thermocouple.c and klippy/extras/spi_temperature.py . However, those chips are really temperature specific while the ads1118 seems more of a generic adc chip. I guess the next step would be to see how #6584 proceeds. Although there doesn't appear to be any code reuse from it, hopefully it will provide a concrete example for similar chips. Thanks again, |
@KevinOConnor I was hoping that both of these 6584 and 6555 would be applicable to a better approach for the ADS1118 code that I wrote, but I think the big difference is that supporting the MakerBot Rep2 (and now this Flashforge Creator) requires "multiplexing" the ADC. Garethky had a good comment about some of the challenges in making this generic enough to be used anywhere https://klipper.discourse.group/t/my-pull-request-broke-the-ar100-build/15591/26?u=dockterj The ADS1118 is weird, it has a mode that makes reading one sensor trivial using just python code (continuous conversion). However, a Rep 2x has 2 thermocouples hooked to it and then you have to read the internal (CJ) temp. This can only be done in one shot mode where you tell it to read the next channel at the same time you pull the reading for the previous channel. The synchronization to make that work seemed to me to naturally be handled on the mcu. Not saying it couldn't be done with just python but it seemed simpler to make a c module for it. Also, give that my target is specifically hotends I thought implementing the mcu safety checks for temp out of range errors was better (I didn't investigate if other hotends were implemented in only python or how the safety checks were handled). Feel free to take a look and I'm open to any feedback. master...dockterj:klipper:master Most of the code is for ADS1118 support - should be obvious which to ignore in that. Note that I used src/thermocouple.c as a starting point, so hopefully it isn't too far out. |
Added firmware and klippy driver for Texas Instruments ADS1118 ADC chip. The ADS1118 is an ADC chip with an SPI interface. It features an internal temperature sensor and can be used to read temperatures from thermocouples. Implemented are reading from the internal temperature sensor and k-type thermocouples. The Flashforge Creator Pro2 printer uses this chip for measuring extruder temperatures. Signed-off-by: Christoph Nelles <klipper-fw@evilazrael.de>
Added basic configuration for dual extruder printer Flashforge Creator Pro2. Macros for IDEX, copy & mirror modes. Internal diplay not supported. Signed-off-by: Christoph Nelles <klipper-fw@evilazrael.de>