Reply to topic  [ 21 posts ]  Go to page Previous  1, 2, 3  Next
W1209 Temperature control Switch (HCTHER0006) 
Author Message

Joined: Wed Aug 21, 2013 7:38 am
Posts: 29
Post Re: W1209 Temperature control Switch (HCTHER0006)
eForth words and memory dump running on other STM8S boards, not yet verified with the W1209!

WORDS <enter>
IRET SAVEC RESET RAM NVM LOCKF ULOCKF LOCK ULOCK ADC@ ADC! WORDS .S DUMP ALLOT VARIABLE CREATE DOES> ] IMMEDIATE : ; ." $" ABORT" AFT REPEAT WHILE AHEAD ELSE THEN IF AGAIN UNTIL BEGIN +LOOP LOOP DO NEXT FOR $," COMPILE [COMPILE] LITERAL CALL, C, , ' [ \ ( .( ? . U. TYPE U.R .R CR SPACES SPACE NUF? KEY DECIMAL HEX str #> SIGN #S # HOLD <# DIGIT PACK$ ERASE FILL CMOVE @EXECUTE PAD HERE COUNT +! DEPTH PICK 0= ABS NEGATE NOT 1+ 1- 2+ 2- 2* 2/ EXG */ */MOD M* * UM* / MOD /MOD M/MOD UM/MOD WITHIN MIN MAX < U< = DNEGATE 2DUP ROT ?DUP FILE HAND BG TIM BL OUT '?KEY 'EMIT hld BASE - 0< OR AND XOR + UM+ OVER SWAP DUP 2DROP DROP NIP >R R@ R> I C! C@ ! @ B! 2C@ 2C! 2@ 2! EXIT EXECUTE LEAVE EMIT ?KEY TX! ?RX hi 'BOOT OUT! COLD ok

HEX <enter>
8080 0F DUMP <enter>
8080 CC 80 A0 AE 0 0 27 7 72 4F 0 0 5A 26 F9 AE L_ .__'_rO__Z&y.
DECIMAL <enter>


Last edited by barewires on Sat Jun 03, 2017 4:54 pm, edited 2 times in total.



Thu Jun 01, 2017 7:02 am
Profile

Joined: Sat May 13, 2017 12:43 pm
Posts: 14
Post Re: W1209 Temperature control Switch (HCTHER0006)
There is a Forth introduction on the W1209 Forth web site: https://github.com/TG9541/stm8ef/wiki/S ... rogramming

It looks rather complete, but the word DUMP you showed was not mentioned. There is also a nice little word for inspecting the data stack: .S

Code:
 1 2 3 4 5<enter> ok
swap<enter> ok
.S<enter>1 2 3 5 4 <sp  ok
.<enter> 4 ok
.S<enter>1 2 3 5 <sp  ok


Thu Jun 01, 2017 5:39 pm
Profile

Joined: Wed Aug 21, 2013 7:38 am
Posts: 29
Post Re: W1209 Temperature control Switch (HCTHER0006)
DUMP is a word apparently running on the HCTHER0006: In the W1209.ihx Intel hex file the ASCII characters are in the code for the word table.
http://www.asciitable.com/
Flash resides at 8000 - 9FFF, 8000 - 807F are 32 Interrupt Vectors and code begins at 8080.
HEX A000 8000 - decimal . 8192 ok
https://en.wikipedia.org/wiki/Intel_HEX
The word in the table is preceded by the number of bytes in this case 04 for DUMP, just before the word and ignoring the last two bytes which is the checksum of the previous hex line. The code following DUMP is the STM8S machine language code.

cat W1209.ihx | grep '44554D50'
:2092A000CD8BAFCD8B4BCD846C200CCD933F830003CD8BAFCD883ACD835092AB81926C0400
:2092C00044554D503B0065CD8A40CD8C1090629089CD8B72830010CD8617ADBECD8605CD56

If anyone has serial communications working on the W1209 could you share the schematic and details. I have been concentrating mostly on the other HC STM8S103 boards.

search.php?search_id=active_topics from May 2017, many pages.

The details on https://github.com/TG9541/stm8ef/ are not entirely accurate and complete and it requires our input to correct and add to the project.
eg. fibunacci [sic] code shows the word 'last' but it does not compile.
: RECURSE last @ NAME> CALL, ; last?

I have been reading the ST Microelectronics forums and it appears that the Vdd power pin within the 4 pin SWIM programming connector is intended to 'monitor' the external voltage powering the device and is not intended to power the device. Hmm, needs a bit of investigation.


Last edited by barewires on Mon Jun 05, 2017 7:18 pm, edited 2 times in total.



Sat Jun 03, 2017 1:01 pm
Profile

Joined: Sat May 13, 2017 12:43 pm
Posts: 14
Post Re: W1209 Temperature control Switch (HCTHER0006)
Hi barewires,

did you see the instructions in the W1209 wiki ? The serial interface uses some kind of single wire connection:

Code:
             .      .----o CH340 TxD
     (5V)    .      |
       |     .     ---
       |     .     / \  1N4148
      20k    .     ---
       |     .      |
PD6----*----->>-----*----o CH340 RxD
       |     . J1.1 NTC header
       X <- C1 removed, or replaced with max. 22nF
       |     .
       |     .
GND----*----->>----------o CH340 GND
             . J1.2 NTC header
   W1209     .
             .
..............


Maybe one should better use a Schottky diode (e.g. BAT41) instead of an 1N4148.

The image from the HaD project below shows that the circuit is simple (the component in the upper left corner looks like an 1N4148). The pads to the left of the sensor header is where C1 normally sits.

Image


Sun Jun 04, 2017 9:19 pm
Profile

Joined: Wed Aug 21, 2013 7:38 am
Posts: 29
Post Re: W1209 Temperature control Switch (HCTHER0006)
Yes I saw all of the details but didn't get it to work last week. The UART Dongles typically have 3.3 volt signal levels. RxD on a 5 volt system is OK but 5 volt TxD should possibly be reduced. A typical silicon diode drops 700 mV. Schottky diodes are about 150 - 450 mV so that is even worse. We have to drop 1.7 volts. Needs more study. But maybe the diode is for blocking only and there is no consideration given to voltage incompatibilities.

Today I was able to see the "stm8eForth v2.2" message as I grounded and released NRST-Reset so the software seems to work. The diode placement for TxD bothers me as there is nothing preventing a collision with incoming RxD data. I suspect the schematic is wrong and the diode should point inwards with the data being received and prevent outgoing data from colliding. Removing C1 makes sense as the NTC sensor is shared with the PD6 - the designers never anticipated people like us re-purposing a simple thermostat into a powerful development system. There is also a 20K pullup resistor to +5 lurking at the side but no description. Very interesting. Half-duplex is like going back to the 40s or earlier when the sender said OVER when finished transmitting. I can't see how communications are arbitrated.

Alfredo, how did you get yours working? OVER


Mon Jun 05, 2017 9:54 am
Profile

Joined: Sat May 13, 2017 12:43 pm
Posts: 14
Post Re: W1209 Temperature control Switch (HCTHER0006)
I think that the trick with the W1209 half-duplex serial is that "TTL style serial" is negative logic, and it even works with open collector outputs and a pull-up:

* The diode effectively converts the serial interface's push-pull output into "open collector" (or open drain).
* The terminal program reads what it sends (you can tell when characters are garbled)
* The W1209 sensor input 20k pull-up does the rest.

You're right, there is nothing to prevent collision of TX with incoming RX data, but I don't see why it shouldn't work for an interactive console (type, press enter, stand by while the result comes in, type more). I did a test that on a stm8s103 breakout board (using two 10k resistors to simulate the W1209 pull-up) and the picocom wrapper from the website: it works for me!

Of course, for transferring Forth code this only works if the transfer program waits until the console is ready to receive more lines. The wiki says:
Quote:
For transferring programs (or interpreted sequences), STM8EF can be switched to FILE mode which basically replaces the OK prompt by a "pace character" (ASCII VT - a serial ASCII transfer program can use this to synchronize with the compilation progress). After the transfer, the word HAND can be used to switch back to interactive mode.

I did a quick check: the "pace character" method isn't new: look for FILE and HAND in http://www.exemark.com/FORTH/eForthOverviewv5.pdf.

The wiki also mentions the python program "loadserial.py" for file transfer. My code compiled OK but it turned out that the TTY name is hardcoded (/dev/ttyUSB0) - this can be changed easily but a configuration file would be a plus!


Mon Jun 05, 2017 9:41 pm
Profile

Joined: Wed Aug 21, 2013 7:38 am
Posts: 29
Post Re: W1209 Temperature control Switch (HCTHER0006)
Having trouble compiling with SDCC recently I found an error in the Makefile. The -oout has to be changed to -o out as that is the output file designation. Download the code from:
https://github.com/TG9541/stm8ef
https://github.com/TG9541/stm8ef/releases

Code:
cd ~/stm8flash/
echo "00 00 ff 00 ff 00 ff 00 ff 00 ff" | xxd -r -p >factory_defaults.bin
make BOARD=W1209 flash
#Intel hex file W1209.ihx is found in /home/pi/stm8flash/out/W1209
sudo ~/stm8flash/stm8flash -c stlinkv2 -p stm8s003?3 -s opt -w factory_defaults.bin
sudo ~/stm8flash/stm8flash -c stlinkv2 -p stm8s003?3 -s flash -w W1209.ihx


Wed Jun 14, 2017 1:09 pm
Profile

Joined: Sat May 13, 2017 12:43 pm
Posts: 14
Post Re: W1209 Temperature control Switch (HCTHER0006)
Barewires,

-oout works for me (-o out works, too, but strangely -m stm8 doesn't work). This sounds like a (benign) bug in SDCC.

What's your version of SDCC ( sdcc --version)?


Fri Jun 16, 2017 8:51 pm
Profile

Joined: Wed Aug 21, 2013 7:38 am
Posts: 29
Post Re: W1209 Temperature control Switch (HCTHER0006)
Very interesting! Running 3.4.0 #8981 (Jul 11 2014) (Linux)
Latest files at https://github.com/TG9541/stm8ef/
I will use the latest hex files provided from now on and avoid the time wasted trying to compile locally.


Fri Jun 16, 2017 9:13 pm
Profile

Joined: Sat May 13, 2017 12:43 pm
Posts: 14
Post Re: W1209 Temperature control Switch (HCTHER0006)
Hi Barewires, I think you'll like this: https://wiki.forth-ev.de/doku.php/en:projects:e4thcom

4ethcom is a terminal for embedded eForth system with many features (e.g. a half-duplex mode). It also runs on the Pi!


Tue Jun 27, 2017 2:50 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 21 posts ]  Go to page Previous  1, 2, 3  Next

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Thank you to phpBB.com & phpBB.ro.
Design created by Florea Cosmin Ionut.
© 2011 All contents of this site are © Hobby Components LTD