Closed tracing-home closed 4 years ago
Hi Martin, it looks like flashing the board worked fine and we should be looking at potential serial interface problems first. Later on we can still look at tool-chain related things.
I'd like to recommend that you use the W1209-FD binary (the W1209 uses the sensor header for communication and therefore a capacitor on the board must be removed).
Is it right that you're using a 5V compatible "TTL-serial interface" interface connected as shown below and described here?
PS: as far as it matters for this project STM8S003F3P6 and STM8S103F3P6 are equal :-)
Hi, thanks for the quick reply. By now I got the serial interface going following those images you sent (soldered earlier already). Using 5V as well. I modified the Makefile to use v2.2.23.
I get:
STM8eForth 2.2.23 ok
or
17 5 + . 22 ok
So far so good :) I have the strange feeling, the temperature control code is not making it across. The Makefile of W1209-0.2.1 doesn't do anything with it. I can't seem to figure out how to get that compiled and added to eForth
Thanks again. Martin
It's good to read that it worked so far!
If you flash the STM8 eForth W1209-FD binary, not the one from releases (i.e. W1209-FD-forth.ihx) you'll get a blank STM8 eForth system into which you'll need to transfer the Forth code. This can be done with codeload.py in the tools folder or, preferably, with e4thcom.
There is an new solution, the modular build, to which I'll eventually update this project.
Thanks for the pointer to W1209-FD-forth.ihx. I got lost with all the options. That works, though I need to try a bit more. First use of L.dump led to simply dumping one set of values continuously. May there was not data yet...?
To be able to change the code, I'd like to use the sources. So back to only eF. Using
e4thcom -t stm8ef -d ttyUSB0
it started well.
#i main.fs Uploading: ./main.fs
\ W1209 basic data logging thermostat
\ © 2017 TG9541, refer to https://github.com/TG9541/W1209/blob/master/LICENSE
\ Note: not yet tested with real eggs :-)
_<typed ctrl-c here>_
? Msg from HOST Error -259
The loading doesn't seem to work this way. Probably me doing something wrong?
I'll look at the modular build option later. Thanks for the tip
You may be right about L.dump. It's also possible that the log interval and other menu settings are still missing (see README.md):
Edit: found it.
Before using the thermostat, please reset the parameter values by holding the keys + and - until the text rES. appears on the LED display (about 4s). Pressing the set key leads to the parameter menu. The menu returns to the temperature display when no key is pressed for more than 10s.
Did you try downloading into the Forth system from W1209-FD-forth.ihx? I can think of two problems:
After doing the reset, and doing the settings 2 things happened:
L.dump 0 0 37.5
...
0 0 37.5 37.5
100 0 23.4 24.1
100 0 23.9 24.4
ok
So data slots to which nothing was saved yet show some pre-initialized data. Here 2 values are actually measures. In total there are 290 lines.
Did you try downloading into the Forth system from W1209-FD-forth.ihx?
Yes. Strangely, after the temp logger was running before, the temperature logger was still running. Writing W1209-FD-forth.ihx didn't remove it. Typing "reset" in the terminal did.
Loading with #i main.fs
now works. After typing "cold" as instructed, the display just goes haywire. LED1 blinking. Pressing + and - until res shows, has no further effect.
The effects you're observing are really surprising :-)
With reset I meant the Forth word RESET
(sometimes using a consistent typeface helps). After running and then doing a cold start the LED display should show the 70s "4th" glyph. If not then there might be something wrong with the binary (e.g. one of the W1209-CA variants).
It's also possible that the symlink target
doesn't point to the version right out/W1209-FD/target
. The words in that folder contain addresses that must mach the binary that loads them (-> ALIAS). Using non-matching addresses may break the Forth system in unpredictable ways.
Another possible cause is the weak spot of using the key inputs for simulating a serial interface: the inputs indicate pressed keys. Please disconnect the serial line and check again.
Edit: if the above doesn't provide a solution I'll grab a board in the evening and give it a try. Maybe this is a case of "bit rot".
I took a fresh copy of the code and one of my W1209 boards and typed make flash
and used e4thcom transfer the code.
The only problem I observed was that L.dump
doesn't stop unless there is at least one log entry (this is going to be fixed together with upgrading the build process).
Did you find the time to check any of the conjectures above?
:) seems to be a habit of mine to find strange things happening
OK, I start over again, here is the protocol:
On this page
this link doesn't work:
https://github.com/TG9541/W1209/blob/master/out/W1209-FD/W1209-FD.ihx
I found it at the bottom of the page:
https://github.com/TG9541/W1209/releases/download/0.2.1/W1209-FD-forth.zip
To flash it, I don't go through make but just execute:
stm8flash -c stlinkv2 -p stm8s003f3 -w W1209-FD-forth.ihx
First run I got "Tries exceeded", second run all is fine. LED1 is on, display shows temp. Now reconnect serial, type L.dump, I see three old values from before.
run RESET from console, power-off, power-on. 4th on display.
run #i main.fs, ends with
RAM ok
\ Done. Type COLD to re-start!
Closing: ./main.fs ok
Display shows 4th. I type cold as suggested. The 7s display mad again: numbers or just segments running extremely quickly, possibly counting with highest change on right digit. And LED1 blinking.
Power-off/serial unplugged, serial connected, power on, there is no "STM8eForth 2.2.23 ok" message, display the same.
Now just stm8ef-2.2.23
stm8flash -c stlinkv2 -p stm8s003f3 -w W1209-FD.ihx
STM8eForth 2.2.23 ok
#i main.fs
ends with
RAM ok
\ Done. Type COLD to re-start!
Closing: ./main.fs ok
cold
Now all is fine. I get the temperature displayed and LED1 on
Now L.dump still gives the same values as before. They must be well hidden away from the flashing :)
Getting daring:
reset
STM8eForth 2.2.23 ok
#i main.fs
cold
Still back to normal temp display and l.dump record remains. L.wipe does eliminate all.
Sooooo :) What remains is that W1209-FD-forth.ihx
is not really RESET
able for some reason.
Seems we wrote at the same time. Running L.dump after L.wipe, the output will stop. You do expect that is outputs the whole table with default values? (0 0 37.5 37.5)
First of all, congrats for successfully completing a crash course in one of the most exotic targets on this planet: a cheap thermostat with an integrated compiler :-D
Regarding your findings... a possible explanation is that I fixed something from the release to the current version but somehow managed not to make a new release. It's also possible that there is indeed an incompatible set of ALIAS words due to the specific steps you made (e.g. old binary, new code). Anyway, it's great that it works now, and a new release will follow soon :-)
Rightly observed - L.wipe
just fills the log memory with zeros. The code is very simple:
: L.wipe ( -- )
\ wipe data log memory
ULOCK L.START L.END OVER - ERASE LOCK
;
The log is in the EEPROM memory - for stm8flash that's a different memory space. You can peek in that memory by typing $4000 639 dump
(RAM starts at 0, Flash at $8000).
Hi Thomas,
:-D I think the crash course is just starting! I got this "heading down the rabbit hole feeling". Forth still looks rather mysterious to me (C is known better, though I am not good). Actually the journey began by wanting to bake sourdough bread. That should be kept at a particular temperature. A bought device was a disaster. Thus the journey began...
I still have the "going through the code" as adventure ahead of me. A couple more W1209's are in the post.
So I'll look forward to that release.
A quick try with a fresh W1209-0.2.1.tar.gz. make flash
fails. Even after changing the Makefile to STM8EF_BOARD=W1209-FD (with make clean in between)
Makefile:15: recipe for target 'flash' failed
make: *** [flash] Error 255
And the 7S display is messed up ...
Now, with a working device, I can start playing around :) I can see that $4000 639 dump
is slowly getting data as the log gets entries. Thanks for explanation
Edit: My goof, W1209-0.2.1 does get forth on there, but serial fails.... I think I should stop for the day :D
Sourdough bread, that's a good application for the thermostat! When I was a kid my mother learned the art of keeping the starter healthy from an old local baker. My sister used to bake hermans and later we made yogurt or kefir. For breeding chicken my grandfather used a contraption that worked without a thermostat ;-)
Forth is actually a good fit for doing embedded control. In my former job I used C for similar things but I guess that using Forth I'd be able to outperform my former C-coding self. For normal data processing and scientific computing I would rather use something else.
Did you have a look at the STM8 eForth "tutorial" page and the technical pages? If you see things that are difficult to understand or things are simply at the wrong place it would be great if you could provide feedback, e.g. by writing an issue.
Some hints: for my test I used the current master, i.e. this zip fiile. For your next experiments better fork the repository so that you have some autonomy (or at least clone it).
If you have more W1209 in the post then... do you expect them to come with an STM8S003F3P6 or are you just used to soldering TSSOP20?
An analog contraption without thermostat? Sounds exciting! Having been born before the digital age, I always sense this conflict between analog and digital. At the same time embracing digital stuff. Since you talk of Hermann and Kefir, I suspect you are, like me, Germany based? Getting OT here :)
I had a look at some Forth tutorial(s), mostly to try to understand the basic syntax and first steps. As I didn't have the W1209 available, I tried myself with gforth and this tutorial: gforth tutorial. As an absolute beginner on forth and micro controllers, I was missing some some initial things on your page: get this app, start it, then the "hello world". The info is there, but the "mental network" only builds after reading several pages. Anyway, I'm happy to provide input there, as a beginner I see other problems than someone who is advanced. Either via "issue" or PMs.
For the time being, I cloned the repository. I do that with the other stuff too. I suppose I could contribute with forking.
Regarding the hardware: I am using W1209 modules and simple development boards I ordered in Germany (at almost China prices). Some STM8's, circuit board and other bits are on their way from China. Soldering itself is not an issue and I'll practice with TSSOP20. At this cost, frying some is no drama. Bit-rot to partially broken ones can be a problem though :(
One reason to move away from the W1209 to a self-built solution lies in the fact that the relay is not rated at 240/250V and I cannot find one with the same form factor as the onboard one. Plus I envision other possible projects.
Out of curiosity, why do you use the pins PC4/PC5 for the serial? On the pinout I see PD5/PD6 labeled as Tx/Rx .
@tracing-home yes, I'm German but "Hermann" only gives it away when you write it with capital H (I learned that sweet sourdough was an international trend!). You'll find some stuff about me are on my HaD profile. The "chicken breeding contraption" was a small cylindrical Styrofoam box with a small ceramics light bulb-like heating device (I still have it somewhere) that could be lowered into the box. At one side of the box there was a thermometer. Every now and then my grandfather used to check the temperature or open the box to rotate the eggs. No thermostat involved, but I'm sure it would have made breeding easier :-)
Thanks for the feedback on the tutorial! Writing about the first steps is best done by people who're actually beginners at the time of writing. Maybe you'll find something useful in my HaD logs or on @andrewsclapp 's HaD page. Andrew started recently and his write-up is certainly good.
The mystery of the ports: the W1209 uses PD5 (Tx) for Seg-A and PD6 (Rx) as the sensor input. The only GPIOs that can support a dual use are the key inputs PC3, PC4 and PC5. If you don't need the display then of course it's possible to have a perfectly fine 2-wire UART link using PD5. But then you can also use e.g. a C0135 board.
I share your concerns about the electrical safety of most of the thermostat boards. I'm also a bit skeptical of relays (20 years ago I've seen one setting a vehicle on fire) and for my solutions I prefer using solid state relays.
Since you're in Germany (or EU), we also have one more option: I've been working on a "platform" for things like my solar water heating controller (using KiCad). Ordering PCBs up to 10x10cm^2 from China is cheap but I don't need that many and I kept adding features to make it an "eierlegende Wollmichsau". I'll now have the time to simplify and finish this project and it would be great to have someone to team up with.
Thanks for the explanations about the hand operated thermal control :)
I had looked at SSRs myself and agree they could be more useful. Then read some review of someone who had taken them apart and found underrated triacs and decided more component research is needed. So if you have recommendations, I'm happy to hear them.
The explanation regarding the pin usage helps. For now I would like to keep the display, so no change.
Actually I am in Bremen. I had a quick glance at the nrf24stm8l project, I guess that is the one you mean. Plus HaD Solar water heating controller. Looks interesting, possibly I could contribute. At this moment I wanted to out, so I'll read more later.
Eben auf Deutsch: Manfred Mahlow, der Autor von e4thcom wohnt zufällig auch in Bremen. Im Dialog mit ihm und einigen australischen Forthern (allen voran @RigTig) ist STM8 eForth von einem Hack zu einer kleinen Plattform geworden.
Hier ist seine Vorstellung von STM8 eForth von der Tagen der Forth-eV 2018: https://wiki.forth-ev.de/lib/exe/fetch.php/events:stm8_eforth._ein_semi-tethered_forth.pdf
Is ja 'nen Ding, noch ein Bremer. :) Na, es freut mich zu der Truppe gestoßen zu sein. Es wird sicher eine steile Lernkurve für mich, aber die Sache an sich finde ich interessant.
Hi. I have a W1209 with STM8S003F3P6 on board. After the successful flashing I am stuck with the "4th" display. Long pressing "set" has no effect.
I ran
with output:
To me that looks good. I also tried (after make clean) W1209-FD with the same result. W1209-CA puts garbage on the display.
I'm a bit unsure about the voltage to give the board from the stlinkv2: 3.3V or 5V? I have read both somewhere. I tried both anyhow.
Should the setting work when powered only thought the stlinkv2? I do I need to swap to 12V? Tried disconnecting the stlinkv2 and connect 12V but I got no further than "4th"
Flashing W1209-0.2.1 results in the same, I only get the "4th" display. I guess stm8ef-2.2.23 is just the forth environment. W1209-0.2.1 is the temperature logger??
Changing the makefile from stm8s103f3 to stm8s003f3 has no effect. But I can't figure out how to do a full compile (I have a working sdcc)
I have the feeling I am missing something basic here :(
Thanks for any pointers. Martin