zondag 13 december 2020

Arduino Elecrow EL Shield

A long time ago i ordered on Aliexpress an Arduino EL-shield as it seemed interesting to play with it. Due to other priorities i never found time to play with it. When looking in my box with Arduino shields i decided to do a quick test. 

EL wire is flexible plastic wire that glows brightly when high-voltage AC is applied to it.

Numerous cool colors are available. They requires very little current, but it can be difficult to work with because of the high-voltage requirements. The Elecrow EL Shield enables you to implement up to 8 channels of EL wires or tapes in an Arduino  project to control the EL modules. 
The controlling method is as simple as controlling an LED. Driven by PWM, it can create a colorful and florid effect by controlling each EL wire according to your own programs.
With the shield 4 pieces of 2 meter are included The shield has 8 channels. See table below.

Pin

PINEL Channel to ControlPWM?(My Wire)
D2EL Channel A-
D3EL Channel BPWM( Blue )
D4EL Channel C-
D5EL Channel DPWM( Orange )
D6EL Channel EPWM( Green )
D7EL Channel F-
D8EL Channel G-
D9EL Channel HPWM( Yellow )


On the Arduino Uno Pin D3 D5 D6 D9 are PWM pins.
Therefore i decided to use these pins for the EL wires. ( Also tested the other channels on the EL shield and they all worked. However on D2 D4 D7 D8 there is no PWM )
When the EL wires are not powered and give no light the color is a bit different. I added in the table above the colors of my wires. 


The EL modules needs a driver voltage more than 110V, AC. The included Elecrow customized inverter can convert the 5V-DC input to AC,110~220V. 
Connected the inverter to EL-Shield as below:
The input wire of the inverter is red/white, which need to be inserted into the DC_5V terminal of EL Shield, and the output wire(black) of the inverter need to be inserted into the AC>110V termina
Specs say that can drive a max of 15m EL wires. 4 x 2 m = 8 meter EL wire was included so lighting them all up at the same is no problem.
As this is all the EL-wire i have i could net test adding additional EL-wire.

In the instruction ( https://www.elecrow.com/wiki/index.php?title=8-Channel_EL_Shield ) First the Arduino is connected to a computer and a script is uploaded. After that the Arduino is disconnected from the computer. The shield is plugged in and an external mains power supply is used. As there is a high voltage on the shield (also near to the Arduino USB connector) i think this is the best way to prevent damaging your computer.
For some applications it would be interesting to see how long this shield can run on a 9 volt battery.
The disadvantage is that you need to plug and unplug connections when playing with the EL-shield. It also makes testing and debugging Arduino programs for this shield a little more difficult. An option could be creating a test with leds connected to D2 to D9 or using an good opto-isolation in the USB to your computer.

When running programs like the provided test program the system emits some low volume beeps and a buzzing sound. It is not a loud noise however i think it is important to mention it. It is possible the sound depends on the amount of power used by the wires and that only 4 of the 8 wires are connected.

On the EL-shield is also a red power led.
// EXAMPLE PROGRAM FROM THE ELCROW WEBSITE
void setup(){
 for(int i = 2; i<10; i++)
 { 
  pinMode(i, OUTPUT);
 }
}
 
void setEL(int ch) // set a certain EL on
{ 
  for(int i = 2; i<10; i++) // all on
 digitalWrite(i, HIGH);
 delay(1000);
 for(int i = 2; i<10; i++) // all off
 digitalWrite(i, LOW);
  for(int i = 2; i<10; i++) // 
 {
  digitalWrite(i, HIGH);
  delay(200);
  digitalWrite(i, LOW);
 }
 } 
 
int count = 0; 
 
void loop()
{ 
 setEL(count%4 + 1);
 delay(200);
 if(count++ == 1000)
 { 
  count = 0;
 } 
}
 
( The % in the Arduino program above is the modulo operator : count%4 is 'counter modulo 4 ' )


Conclusion:
  • An interesting relative cheap Arduino shield.
  • The (2 meter long) EL-wires give an interesting light effect for a project. Perhaps for your project you will need another color or more wire of the same color. (I did not test other El-wires.)
  • Due to the high voltage generated by the 'Elecrow customized inverter' i did not want to take risks trying the EL-lights with the USB connected to my computer. A USB opto-isolator or a test shield with leds to D2 to D9 would be useful.

 






zaterdag 12 december 2020

Using Forth on my ELF II

Using Forth on my ELF II computer (including a CREATE DOES> explanation ) is the second article in a series about me and using Forth that started with my blogpost “My first computer and Forth” 
With Forth running on my ELF II computer with its RCA 1802 processor now real high level coding was possible.
I used virtual disk blocks with code stored in memory (loaded and saved to my system using audio cassettes). For coding in assembler an 1802 assembler in Forth was available. Also Forth text editor was published in a Forth magazine. I controlled hardware with Forth (an AY-3-8910 audio chip that I had added to my system). Forth became one the most important work horse on my system

In Forth you can new own words in vocabularies using : ; Do (complex) math in RPN using a (Forth) stack. Add extensions for floating point and strings. In my opinion one of the most powerful features of Forth is CREATE DOES> ( in the fig-Forth version when i started with Forth  <BUILD DOES> ).

Explanation of CREATE DOES>

Before i can explain CREATE DOES> (or <BUILD DOES> as it was called when i started with Forth) some fundamentals of Forth must be known. I do not give an in depth explanation however it is always possible to ask questions after reading this article.
Parameters (numbers) in Forth are passed using a stack.
(New) Forth words are stored in memory in a dictionary.
Things you type in using your keyboard are placed in a special memory area, the terminal input buffer. Space or spaces are used as separators between words and there is a character defining the end of line.
The Forth interpreter looks at the first word from the terminal input buffer and tries to find it in its dictionary. If found, there is also code to be executed in the dictionary. If not found Forth tries to convert it to a number and places the number on the stack. If not found Forth shows an error message.
After that (when there was no error) it continues with the next word until the end of line character in the terminal input buffer. The end of line character is just a special Forth word that prints an oke prompt and lets you enter a new line of text in the terminal input buffer.
Defining a new Forth word is placing a new word in the Forth dictionary together with the code that needs to be executed.
Example 1 : ; ( or colon semi-colon ) construction.
: My1stWord DUP 2 + . ;
The : puts My1stWord in the dictionary. DUP 2 + is the Forth code that belongs to My1stWord
; ( semi-colon) indicates that this is the end of the definition made by : ( colon )
Example 2 VARIABLE ( I do not encourage the use variables as often it is better to store things on the stack than in a variables)
15 VARIABLE My1stVar
15 is put on the stack. A variable with the name My1stVar is created containing the initial value 15 . ( I assume you have a Forth system where the initial value is on the stack. it is also possible you have a system where no initial value is needed/used.)
When the new Forth word My1stVar is executed it gives a memory pointer to the address where the value of the variable is stored. To get the value ( 15 ) we can use the Forth word @ This word uses the address (that is on the top of the stack) and fetches the value.
The magic of creating new words is CREATE DOES>
CREATE creates a new word in the dictionary and the DOES> part tells what to do.
Let make the Forth word JVAR to create a variable This is relative simple:
: JVAR CREATE , DOES> ;
: defines the word JVAR
CREATE is a word that creates the dictionary entry. The dictionary entry contains a pointer to the DOES> part. So when the word is found in the dictionary it knows what to do.
, ( comma ) is just a simple word that gets a number from the stack and puts it in the dictionary.
And then there is the DOES> part, in this case seems to do nothing.
When we now enter 12 JVAR My2ndVar The variable with the name My2ndVar is created and available in the Forth Dictionary.
When the new Forth word My2ndVar is executed it gives a memory pointer to the address where the value of the variable My2ndVar is stored. To get the value ( 12 ) we can use the Forth word @
To change this to the behaviour of a “constant” where, when executed not a pointer but the value is on the stack, we could do something like
: My1stCONST My2ndVar @ ;
However this would be an uncommon way to create a constant as this is actually fetching a variable. Creating multiple constants would require for each constant also a variable.
Let us make a word JCONST to create a ‘real’ constant.
: JCONST CREATE , DOES> @ ;
The @ is now in the DOES> part.
32 JCONST My2ndCONST
creates the word My2ndCONST
The DOES> part uses the address and fetches ( @ ) the value.
A very powerful way to make defining words at your own flavor as everything can be adapted in this CREATE DOES> concept.
For example create double size variables initialized with the value 0
: JDVAR CREATE 0 , 0 , DOES> ;
or do you want something else like a constant with a value that increments each time with one when a new constant word is created?

Forth has advantages and disadvantages. Floating point math, use of text strings. It was always a bit different from other computer languages. Most times with what I would call ‘more contact to what is really happening in the system’. I liked using less variables and using the data stack.

In my brain came the idea that the most beautiful programs are the smallest ones. When I was repeatedly typing (almost) the same code (copy and paste was that time not as easy as nowadays) programs could be done differently (and better). When you expect to find here a lot of real Forth code that you can enter in any Forth system I must disappoint you. However I present some ideas and parts of code that you can use in your Forth system if you know some of the internal working of your Forth system and add some code to adapt it to your Forth system.

A (lazy) simple program to control your hardware in Forth only needs
1 :LAMP LAMP_CHILDROOM
2 :LAMP LAMP_LIVING
4 :LAMP LAMP_B
8 :LAMP LAMP_BEDROOM
If you have created a smart defining word :LAMP with your system suddenly can understand what to do when you type
OFF LAMP_LIVING
ON LAMP_BEDROOM
TOGGLE LAMP_CHILDROOM
TEST? LAMP_CHILDROOM
I used TOGGLE to switch it ON when the light was OFF or switch of OFF when it was ON.
TEST? to leave TRUE or FALSE on the stack depending on the current state.
OFF ON TOGGLE and TEST? can be implemented as constants that each push a different value on the stack.
:LAMP is used to define LAMP_CHILDROOM LAMP_LIVING LAMP_B LAMP_BEDROOM
The 1 2 4 or 8 are stored in these words so later on FORTH knows which hardware bit controls which lamp. The DOES> part is executed when the new defined words are executed.
It gives a pointer to the defined word so the correct hardware bit (and/or other parameters) that was stored during the <BUILD can be fetched.
OFF ON TOGGLE and TEST? pushed a value on the stack so the DOES> part can use it to determine what to do.
So on the stack are the bit/hardware parameters and what you like to do ( OFF ON TOGGLE or TEST? )
SWAP these, so what you want to do is on top of the stack. Using a CASE statement you can continue with the code to turn the bit/(hardware) high, low, toggle it or test the current state (and leave that as a flag on the stack).
To turn all the lights of you need something like
OFF LAMP_CHILDROOM
OFF LAMP_LIVING
OFF LAMP_B
OFF LAMP_BEDROOM
or
OFF OFF OFF OFF LAMP_CHILDROOM LAMP_LIVING LAMP_B LAMP_BEDROOM
This as each device needs its own control parameter when coded the way described above.
Some people don't like that.
This can be solved in different ways:
Method 2 could be OFF ON TOGGLE and TEST? are not constants that were pushed on the stack. Implement OFF ON TOGGLE and TEST? as words that change a variable
Method 3 could be don’t eat the value of OFF OF TOGGLE or TEST? from the stack.
Change the code so it is after (successful) execution still on the stack. (Otherwise leave a special number indicating there was an error)
Another option could be that you don’t like the spaces between the command and word at all.
2 :LAMP LAMP_LIVING
You do not want to create one word LAMP_LIVING
It should create multiple words (without spaces):
LAMP_LIVING_OFF
LAMP_LIVING_ON
LAMP_LIVING_TOGGLE
LAMP_LIVING_TEST?
This is also possible because :LAMP can define multiple words e.g.
2 2 2 2 :LAMP LAMP_LIVING_OFF LAMP_LIVING_ON LAMP_LIVING_TOGGLE LAMP_LIVING_TEST?
This as you can make :LAMP consisting of multiple defining words like
: :LAMP :LAMP_OFF :LAMP_ON :LAMP_TOGGLE :LAMP_TEST? ;
:LAMP_OFF has a CREATE DOES> to turn a bit off
:LAMP_ON has a CREATE DOES> to turn a bit on
:LAMP_TOGGLE has a CREATE DOES> to toggle a bit
:LAMP_TEST? has a CREATE DOES> to test a bit
Each of the defining words needs to know the hardware bit (in this case 2)
It is strange and can give errors if you need to do it as described before repeating 2 2 2 2.
Again this can be solved multiple ways:
One method is by duplicating the hardware bit (Except the last time)
: :LAMP DUP :LAMP_OFF DUP :LAMP_ON DUP :LAMP_TOGGLE :LAMP_TEST? ;
Another method is to make the code of the defining words :LAMP_OFF :LAMP_ON :LAMP_TOGGLE :LAMP_TEST? keeping the hardware bit on the stack
: :LAMP :LAMP_OFF :LAMP_ON :LAMP_TOGGLE :LAMP_TEST? DROP ;
The last word does not need to maintain the bit on the stack. However for consistency it let all words keep the hardware bit and DROP it at the end.
This way if you later-on add a new thing like :LAMP_BLINK you do not need to check which words change the stack.
This all to reduce the code from
2 2 2 2 :LAMP LAMP_LIVING_OFF LAMP_LIVING_ON LAMP_LIVING_TOGGLE LAMP_LIVING_TEST?
to
2 :LAMP LAMP_LIVING_OFF LAMP_LIVING_ON LAMP_LIVING_TOGGLE LAMP_LIVING_TEST?
What about improving the code so
2 :LAMP LAMP_LIVING
would create in the Forth dictionary
LAMP_LIVING_OFF LAMP_LIVING_ON LAMP_LIVING_TOGGLE LAMP_LIVING_TEST?
This is not very difficult. You need to know in detail how (your) Forth creates new words.
CREATE (or <BUILD) gets the new word that needs to come in the dictionary from the terminal input buffer (TIB). Adapt this so you start each time again at the same word LAMP_LIVING and add the _OFF _ON _TOGGLE _TEST?
You need to DIG in your system to check how this is implemented. (Perhaps you have the word DIG to check Forth words).
So modify Forths so not the next word from the terminal input buffer is fetched (and eaten) but a word is defined including _OFF _ON _TOGGLE or _TEST?

Unfortunate i learned that in eForth there is no CREATE DOES>.  However i expect some of the ideas presented still can be used. For example modifying the defining words so not only the word comes in the dictionary, also with suffixes appended as _OFF _ON _TOGGLE _TEST?

donderdag 10 december 2020

Testing two interesting 220V led light bulbs

 Recently i received two interesting main volt light bulbs from Aliexpress . These two light bulbs are both equipped with sensors. One has a PIR motion sensor. The other mentions a radar sensor. They both give light when someone is near the bulb and it is dark.
From both lamps several versions are available (Warm of Cold white and different watts).

PIR Lamp


Induction Lampe LED E27 B22 LED Night Light Lamp With PIR Motion Sensor Light bulb Luminaria Auto On/Off Detection Energy-saving.

I ordered 12W Cold White. And indeed it looks very cold white








"Radar" Lamp
Radar Motion Sensor E27 Led Lamp Bulb E27 85-265V Auto Smart Infrared Body Sensor Light Bulb For Home Stair Porch Aisle Garage
I ordered a 10W Cold White version

To compare the light bulbs i used a lamp socket with a main ( 220V ) connector and did some tests.
The led lamp with the PIR sensor has a little (additional) ball on top (for the sensor).
The led lamp with the 'radar' is, by just looking at it difficult to distinguish from an ordinary led lamp.


When connecting to mains both lamps first go on. I did not check if this was due to the design or due to the fact that i was near the bulbs.

After the last detection both lamps turn off after a delay of about 25 seconds.
After that they both only light up when sensing something if it is dark.
However the lamp with the PIR sensor is more sensible to light and for this lamp it needs to be a little more dark than for the radar lamp to turn on again when approaching the light bulb.

I did some simple tests to see if the lamps turn on when inside a bag, a box, or behind my computer screen. The lamp with the radar sensor was a little more sensible than the PIR sensor lamp. However the radar was less sensible than expected. So i have some doubts if it is really equipped with a radar sensor or just has another type of IR sensor. 
Also during these experiments when placing the PIR sensor in a bag it randomly turned on an of when nobody was near.


For a more extended test two lamps of a similar wattage should be tested including a power consumption measurement. Also a tear-down of the lamps would be interesting to check the sensors used. Especially for this 'radar motion detector lamp'.  At the moment i will not do such an extended test. I have seen some video's and there are several lamps with radar included. I don't know if there is a lot of variation between the sensibility of these lamps. 

To really know if these motion detection lamps will suit your needs and which lamp will be the best for which situation you will need to test them in the real location where you want to use them.

woensdag 9 december 2020

Arduino Uno enclosure

Today received some new mail items for Aliexpress. In the past i received items form each seller separately. However the last months i notice packages from several sellers get combined. I receive now packages containing several separate little packages.

Arduino Uno in enclosure (Front)


One item in my mailbag of today was a plastic Arduino enclosure. They are relative cheap and i have seen several pictures and video recordings where using this enclosure.
I ordered some to check if they fit my needs. Until now i used several times plastics plastic screws with my PCBs to put them better on my table.

Arduino Uno in enclosure (back)


 I like the plastic enclosure. I did find some little disadvantages:

  • Some Arduino shields have relative short legs and do not fit as nice as without the enclosure.
  • When putting a shield for the first time you must bend the shield legs a little, which is done better without the enclosure.
 Also in this blog a photo of the manual for assembling this enclosure. The enclosure came with a spare M2 screw and nut.



donderdag 3 december 2020

My first programmable Car

This week i took some picture of my car to share on my blog.  It is a "Fantastic Car with a Brain". You program the car and you decide the action,





This Hasbro Amaze-A-Matics programmable car comes with some plastic strips with ready to use programs. Also some cardboard strips are included that you can cut to create your own "programs". 




The card with the program is pulled under the car along two mechanical sensors on the left and right.
One side contains information for the wheels ( Left Straight Right ) and the other side info for the motor ( Forward, Neutral, Reverse ).


The programmable car was one of my toys as a child and i expect the first programming experience.
So below probably the first 'programs' ever that i created. Perhaps you can even find my first programming bug. (The white cardboard ones are my programs. The plastic black one is one of the programs the came with the car.
I remember cutting my own cardboard when i used up the pre-printed cardboard provided with this car. 
As the "program" contains no (conditional) branches or loops. In my current definition, i would not call  it a real program. This 'programmable' car (see picture below) perhaps moved me in the direction of computers and Ford Forth. 






vrijdag 20 november 2020

Found Emma 02 an RCA 1802 emulator

Just found Emma 02 , an 1802 Emulator that can emulates several RCA 1802 systems and could not resist trying a quick install, and it worked.

Internet home         https://www.emma02.hobby-site.com/
(Download             https://www.emma02.hobby-site.com/download.html )
Facebook               https://www.facebook.com/emma02.emu/
Github                    https://github.com/etxmato/emma_02

After the easy installation on my windows machine i did run it.
On the tab "Elf" i pushed at the [Start] button. (bottom left)In the green terminal screen 'For help type HELP.' at the >>> prompt type FOR NEW  or FOR OLD start a Forth.
(It is also possible to type FORTH , and the system wil ask OLD or NEW ) 

It is also possible to emulate other 1802 systems e.g. the COMX-35 (an RCA 1802 computer i never owned) that runs a Basic version.

donderdag 19 november 2020

FORTH on Arduino -3- (Funduino Joystick game shield)

Having eForth running on my Arduino testing some I/O is what i wanted. Some years ago i posted https://blog.jeronimus.net/2017/04/funduino-joystick-shield.html about an Arduino joystick / button shield. This cheap shield has a joystick some input buttons. (And some connection headers that i did not use in this test.)  
There are several versions of this board. I have the Funduino V1.A The shield gives your Arduino the functionality found on the old Nintendo controllers. It can be used for gaming or control hardware.
2 analog inputs and some digital Ideal to start with this this shield with eForth to do some simple input tests. 


The table below lists how the buttons are connected to the Arduino 

ArduinoButtonPort&bit
D2Key A UPPD2
D3Key B RIGHTPD3
D4Key C DOWNPD4
D5Key D LEFTPD5
D6Key E StartPD6
D7Key F SelectPD7
D8Analog buttonPB0
A0AnalogX JoystickAnalog0
A1AnalogY JoystickAnalog1


The ForthArduino1.pdf contains several I/O examples that can be tested with this board: 

For the analog ports
Paragraph 3.5 mentions
If you connect an external analog signal source to the A0 pin, then type the following commands to read its analog value:

27 C!    \ setup A0 as input pin, which is on PC-0 port
 1 28 C! \ turn on pull-up resister on A0 pin
40 7C C! \ setup reference and multiplexer inputs
C3 7A C! \ start conversion
78 ?     \ display results 78 = low byte 79 = high byte

Example for digital port  ( D8 PB0 button of joystick)

 0 24 C! \ make all Port B pins input
 1 25 C! \ turn on pull-up resistor for Line 8
23 C@  . \ read PINB port and show its contents

23 C@ . \ repeat with switch on and off

What i especially like about eForth on Arduino is that using the terminal you can interactively test and play with the system to adapt it to your own needs.
The AVR Family databook / ATmega328P datasheet contains detailed info about all the internal registers. Also the multiple functions of the pins are explained.
Also you can find the info that i summarized in the table below.


Data register

Data direction
 register
Input pin address

PortBPORTBDDRBPINB
D8
Analog button
0x05 (0x25)
0x04 (0x24)
0x03 (0x23)
PortCPORTC
DDRC
PINC

0x08 (0x28)0x07 (0x27)0x06 (0x26)
PortDPORTD
DDRD
PIND
D2-D7
Key A - F
0x0B (0x2B)0x0A (0x2A)0x09 (0x29)





For reading the other buttons you need to read portD.
 0 2B C! \ make all Port B pins input
FF 2A C! \ turn on pull-up resistor for all lines
29 C@ .  \ read PINB port and show its contents

Some simple words to play with the shield and print the output :
: .PD  0 2A C! FF 2B C! 29 C@ . ;              / Print PortD  ( Buttons)
: .PB  0 24 C!  1 25 C! 23 C@ . ;              / Print PortB ( Joystick button)
: .PX 27 C!  1 28 C! 40 7C C! C3 7A C! 78 ? ;  / Print Joystick X value
: .PY 27 C!  1 28 C! 41 7C C! C3 7A C! 78 ? ;  / Print Joystick Y value
: .JOY .PB .PX .PY ;                           / Print all Joystick values

I used short cryptic words like .PB. More descriptive would be .PrintPortB, For playing with the system it would require more typing more characters. 

In Forth it is also possible to change the output to binary to easy see the bits corresponding to each button:
2 BASE !   /  Set Binary output 
HEX        /  Set Hexadecimal output

Hope this Arduino Forth ( eForth) introductory blog article can be help others starting to use Forth on Arduino.

dinsdag 17 november 2020

FORTH on Arduino -2-

When i wrote FORTH on Arduino -1- i had some open questions. Now i have some answers and info how to proceed. I did not try it yet. However i like to post it as a short quick update about  eForth in my 'FORTH on Arduino' series.

- To trick the Arduino so it will start a special Forth word if no terminal input is received within a certain time or depending on a High or Low value on an Arduino pin to create a simple reconfigurable embedded Forth system. should be quite easy. In the book 'eForth and Zen' and especially the ForthArduino_1.pdf  ( Tao of Arduino ) by Dr. Chen-Hanson Ting is info how to create a turn key system that, after a reset or at power on starts with Forth word.
A quote from chapter  "3.6 Build a Turnkey Application" where a forth word APPL is created:

To turnkey this application so that it executes APPL command on booting-up, type the following commands:
' APPL 'BOOT ! \ store address of APPL in variable 'BOOT
$100 ERASE \ erase flash
$100 $100 WRITE \ save RAM $100-17F to flash $100-17F
$180 ERASE \ erase flash if this page is used
$180 $180 WRITE \ save RAM $180-1FF to flash $180-1FF

- Using I2C can be done in different way. i would like to use the Arduino library and interface this to Forth. This to also know how to use other Arduino libraries and code that already works in a 'plain Arduino environment'.  I am still looking for more info about this.
Another option is controlling the IO pins fir I2C direct from within Forth as e.g. explained in   https://arduino-forth.com/article/arduino_I2Cinterface


FORTH on Arduino -1-

 FORTH on Arduino

Before trying to install a Forth where changing the bootloader is needed i wanted to experiment with Forths that are more 'plug an play'.

First i tried Yaffaforth

After downloading unpacking it tried to compile it. Seemed that it also needed install FreeMemory. After installing this and spending more time than desired it still kept giveing error messages e.g. 'ip' was not declared in this scope .

As in the Yaffaforth information i found on internet a relative old Arduino version is used and the Yaffaforth is also relative old i decided to try stop and try another Forth for Arduino.

Therefore i moved to eforth of Dr. Ting . This Forth compiled without problems on my PC. Also uploading to the Arduino was easy.

The only issue that needed to be fixed was my terminal configuration. In the code i found the baud-rate and i needed to adjust some CR LF settings. It looks great however i did not yet had time to read all documentation to find a solution for the following issues:

- I want to use more IO including I2C within Forth on my Arduino.

- BUILD DOES> that later changed to CREATE DOES> is not available in eforth. I wanted to use this like i used it years on my RCA 1802 computer.

- How to trick the Arduino so it will start a special Forth word if no terminal input is received within a certain time or depending on a High or Low value on an Arduino pin. This to create a simple reconfigurable embedded Forth system.

So i still have a lot to learn and hope to post something about this process on this blog.. eforth seems a great Forth for Arduino. It was easy to install was for me worth the time spend and i want to investigate it further as you also seem to have access to all arduino libraries.

maandag 16 november 2020

EPROM programmer -2-

This is part 2 of my post about my EPROM programmer. I did not yet tested the EPROM programmer however i want to report that i have tested the I2C_EEPROM that i mounted on my board.

As i mentioned in my last post , having an EEPROM on a UV EPROM board is perhaps a little confusing. It think it can be a valuable add on. Use cases for the additional EEPROM can be;

  • using the EPROM programmer as stand alone device to write the same program to several EPROMs
  • reading several EPROMS to the EEPROM for later investigation
  • comparing EPROMs with EEPROM
  • creating an EPROM emulator
  • using a spare PCB of this programmer to add an I2C_EEPROM to a project (most PCB manufacturers (like JLCPCB send out multiple PCBs)
  • .........

I have recently tested an I2C EEPROM on my PCB and it works fine.
The first sketch used for testing is the sketch below (as found at several places on the internet) and some variants i created of it:
/*
* I2C EEPROM sketch
* this version for 24LC128
*/
#include <Wire.h>
const byte EEPROM_ID = 0x50; // I2C address for 24LC128 EEPROM
// first visible ASCII character '!' is number 33:
int thisByte = 33;
void setup()
{
Serial.begin(9600);Wire.begin();
Serial.println("Writing 1024 bytes to EEPROM");
for (int i=0; i < 1024; i++)
{
I2CEEPROM_Write(i, thisByte);
// go on to the next character
thisByte++;
if (thisByte == 126) // you could also use if (thisByte == '~')
thisByte = 33; // start over
}
Serial.println("Reading 1024 bytes from EEPROM");
int thisByte = 33;
for (int i=0; i < 1024; i++)
{
char c = I2CEEPROM_Read(i);
if( c != thisByte)
{
Serial.println("read error");
break;
}
else
{
Serial.print(c);
}
thisByte++;
if(thisByte == 126)
{
Serial.println();
thisByte = 33; // start over on a new line
}
}
Serial.println();
}
void loop()
{
}
// This function is similar to EEPROM.write()
void I2CEEPROM_Write( unsigned int address, byte data )
{
Wire.beginTransmission(EEPROM_ID);
Wire.write((int)highByte(address) );
Wire.write((int)lowByte(address) );
Wire.write(data);
Wire.endTransmission();
delay(5); // wait for the I2C EEPROM to complete the write cycle
}
// This function is similar to EEPROM.read()
byte I2CEEPROM_Read(unsigned int address )
{
byte data;
Wire.beginTransmission(EEPROM_ID);
Wire.write((int)highByte(address) );
Wire.write((int)lowByte(address) );
Wire.endTransmission();
Wire.requestFrom(EEPROM_ID,(byte)1);
while(Wire.available() == 0) // wait for data
;
data = Wire.read();
return data;
}

However i did first run an I2C scan program to check the ID of the EEPROM. And with the EEPROM connected i found indeed the ID value 0x50 as used in the script.
Reading writing to te EEPROM works fine. Next step to make EPROM programmer working is testing and writing code for the SN 74595 shift registers.


Meanwhile i am also working on a redesign of my EEPROM shield for multiple EEPROMs. I did not yet order my first design at e JLCPCB  as i had some ideas for improvements and features that i wanted to add. 
On my 'Arduino to do list' is also writing a a better memory dump program for these EEPROMs and also running Forth code on the Arduino Uno.

zaterdag 17 oktober 2020

My first computer and Forth

When I needed to select my career it was difficult to choose between chemistry and electronics. I decided to go for (analytical) chemistry and kept electronics as a hobby. In my last years at school computers were just coming. The last years i went to school there where 4 terminals (with one printer) connected (i expect via a phone line) to a computer somewhere else and we had to write some computer programs in Basic as exercise.   

There I became fascinated by computers, did know a little bit of electronics, and after finishing school I started working in a pharmaceutical company. 

I wanted to know more about the link between the electronics and computers. In the Popular Electronics Magazine i found an article about the 1802 microprocessor. That was the first article about a microprocessor where I at least thought that I understood something a little bit. Magazines spread interesting articles over multiple editions, so a month later i also needed to buy the next edition as, i expect for a business model, most interesting articles were spread over multiple editions. After this I did read articles about other microprocessors, however at that time a lot of it was very complicated for me.
As the desire to have a real computer for my own grew I started investigating options. I already had a programmable calculator. Buying a ready computer was, at that time, not an option. The only little affordable options were some microprocessor kits and I decided to buy an ELF II with an 1802 processor.

For me important features were that it had a graphic chip so you could create some (black and white) graphic output to display on a TV and the architecture and instruction set of the 1802 was easier for me to understand than that of other processors. I ordered a kit and after soldering I got the ELF II with its 256 byte (¼ k) ram, the graphic processor, a hexadecimal display, a hex keyboard working and started leaning more.

Very soon I also needed the expansion board with a 256 byte containing a small monitor program. The most important in the 256 byte rom was a program to read and write memory to an audio cassette recorder using simple hardware interfaces on this board.

Some of the 256 byte memory was also used as memory for graphics on the TV. 256 byte (¼ K) is not much so I kept looking at the slowly decreasing price of additional memory.
At some point I decided not to for the 4K ram memory board and made a big jump by buying a 64K ram board with 48K ram. I expect it was around that time that my boss told me that it was a little crazy that I had a computer. However he understood it as i was only living during the weekends with my parents a little more than 200 km away from my work. From Monday till Friday I lived in a small room near my work and could enjoy my computer.

And with the huge amount of memory it became possible using programming languages on the ELF II 1802 processor. However often the programming languages used a terminal on the RS232 interface and that was, after already spending more than a month's salary on my computer, above my budget. However i did buy a kit for an ASCII keyboard over the parallel port. 

There was Chip8, Pilot and from a magazine i did type over a terminal program using the video chip using black and white characters. I could not use Basic as this language needed an external terminal on the RS232 port and there was no info or source code about its internal working.

And then there came Forth. I got a cassette tape and a print of the 1802 programming code for Forth also using the RS232 interface. However the standard Forth interface uses only 3 important routines. ?KEY and KEY to check and get input from the keyboard and EMIT to output one character. Making ?KEY and KEY work was not that difficult and in my first Forth experiments i used the hexadecimal display with a button to go to the next character after reading the HEX Ascii value and decoding it to the ASCII value.

My plan was interfacing Forth with the 1802 terminal program as that seemed possible as the source code of these two programs was available. This was my first real big IT project and I am still proud that I, on my own, could make this work.

The first,and easiest step was to move the terminal program (and video memory) to another part in memory. After that came the bigger challenge. The 1802 processor has 16, almost identical, registers of 16 byte. Each of these registers can be assigned as a program counter, stack pointer, a pointer somewhere in memory or to store a bite in the high or low part. These registers are also used in the Forth implementation for the 1802 processor.
However these 16 registers ( 0 to F) are almost identical, not completely!
R0 was (also) used for DMA, direct memory access for the graphical display chip.
After a hardware interrupt (also used for the video display) R1 became the program counter and R2 became (assembler) stack pointer. Also some of the registers were used in the terminal display program.
As these registers were also used in the 1802 Forth code i needed to change this in the Forth code. Nowadays this would be easy. At that time I did not have a working assembler. Only the hex keyboard, a hexadecimal display, a simple monitor program in the rom to inspect and change a hex address using the limited I/O. And after making changes I needed to store my work on an audio cassette tape to continue on another day.  Printing a version with changes was not possible as a printer was not available. So i used a paper notebook to keep track of changes to do and done.

The video display worked using the interrupt code and DMA (direct memory access). Every time to display memory data on the TV screen the video chip gave an interrupt.. It did set R0 to the beginning of the video memory and some other housekeeping. As Forth and the Terminal program used the registers. Also a small assembler program that saved and retrieved some of the 16 registers in memory when going from Forth to the Terminal display program and vice versa was added.

After many evenings of work the changes in the code where ready and the Forth ok prompt appeared on my black and white television and my adventure could continue on a higher level. 

donderdag 8 oktober 2020

EPROM programmer -1-

I have several old UV erasable EPROMs that i want to use.
The UV EPROM ereaser orderd on AliExpress for using the EPROMS came sooner than expected. Now i also have received the PCB that i designed for the programmer and soldered some components on it.
For the programmer i wanted to use an Arduino and an external power supply for the programming voltage. The datalines will be directly connected to Arduino pins. For the address bus using a counter (or bigger an Arduino with more pins) would be the most easy solution. I want also to read data and select addresses without the need to count. In this first test circuit i want to use an Arduino Uno and a shift register to output the address.

As the PCB had some open space and there where also some unused lines from the Arduino and the shift register. I decided to add some useful (optional) bonus items on the PCB.

  • Pushbuttons (reset and an extra)
  • Leds
  • Buzzer
  • Voltage divider with two resistors to measure the programming voltage with an Arduino analog input port.
  • EEPROM (additional storage)
    Having an EEPROM on a UV EPROM board is perhaps a little confusing. It think it can be a valuable add on. Use cases can be; using the EPROM programmer as stand alone device to write the same program to several EPROMs, reading several EPROMS to the EEPROM for later investigation, comparing EPROMs, creating an EPROM emulator etc.

 


The first item i want to test on this PCB is the EEPROM. I hope soon on my blog will appear a post about this.
Testing of the UV EPROM i want to do after having more (programming) experience with the shift registers.
A project currently in progress is a special Arduino shield PCB to test and play with shift registers (and leds) This is a separate project i want to do before real EPROM programming. I ordered my EPROM programmer PCB at JLCPCB with the cheapest (slow) shipping service together with some other PCBs including the shift register test shield. With JLCBP (and some other PCB manufacturers) you currently get multiple PCBs for a very low price.

A project i want to do is a EEPROM test shield. I already designed this test shield however first i want to test my EEPROMs (using this EPROM shield) before ordering the EEPROM test shield.

There are also some other finished projects i want to publish on my blog. I hope you visit by blog again soon, and by that time there is also a post about my first EEPROM test results. 



dinsdag 6 oktober 2020

Metal detector -2-

 After building the metal detector kit from the first blog post i received another DIY kit from Aliexpress for a metal detector. From this version i ordered (and received) two. Until now i only assembled one) . I did not (yet) find the circuit used in this version however as it contains other parts as than the first kit the circuit must be different.

The kit contains more transistors than needed so after building an testing i now have some extra transistors. An instruction manual or schematic was not included. Information which components to place where was on the PCB



I included a photo of the front and back of the PCB.

After assembling i powered the metal detector using 3 1.5 AA batteries (= 4.5V). This metal detector seems to work better than the one in my Metal detector -1- blog post. This second metal detector only has a buzzer. not an led. See picture below. It only gives a signal when metal is near the PCB. (It is possible to create a (false) signal by moving the batteries and battery wires near the detection coil. The pot meter can be used to adjust the sensitivity.

I have found a circuit for a metal detector using a 555 timer and i have some of these 555 times i stock.
Perhaps, some time, i also build a metal detector using the 555. However i  am also working on other projects and received some PCBs and other components for these project. And for now i have a nice working metal detector so i want to give priority for these other projects. 


zondag 4 oktober 2020

Metal detector -1-

Recently i did buy this cheap DIY metal detector kit at Aliexpress.

Here some pictures of the parts ant the assembly. Soldering the components was not very difficult. As i wanted to use the power screw terminals in another project i soldered two Dupont pins instead for the power. In fact is was a three pin male Dupont pin where i removed the middle pin. The two outer pins where at exact the right distance on the PCB.




Below the circuit diagram for this metal detector found on the internet 


I did build and tested the device powering it with 3 1.5 volt batteries (=4.5V) on the Dupont pins. My device continuous gives a signal that changes a when near metal. Changing the pot meter gives a change in the sensibility.This metal detector continuous gives a sound. Don't know if this is due to an error or intentionally. I did not do much troubleshooting to see if it was due to an error made during building and if i could improve it as i don't like it.

This is part -1- of my post about a metal detectors as i also ordered another cheap metal detector and i want to compare them.

maandag 28 september 2020

EEPROMshield

The PCB design of my EEPROM test/development shield is ready. 
Hope to post soon (after receiving the PCB), more details and test results of this Arduino shield on this blog.
This PCB is a breadboard friendly Arduino shield for multiple EEPROMs.  September 2020 the final design (using EasyEDA ) for the first version this board was ready. However i decided to wait for ordering  this PCB until i tested an EEPROMs. 

zondag 30 augustus 2020

Mailbag 29 augustus 2020

Below new mailbag items.
As they are often needed for small projects some switches. On the photo you can see the foam package for protection during the transport.

 
As for less than 5 euro's it is possible to buy a small weighing scale on AliExpress For long time i had this on my wish list and some weeks ago I decided to buy one (300g/0.01g.). Not only can it become quite handy for counting electronic parts, I also hope to find time for chemistry or physics experiments. I expect it is more easy to use than the old analytical balance i have. When i started doing chemistry experiments many years ago i did never dream i could buy this instruments below 5 euros. I hope to do a full review including testing with some weights. What i already can say, it is small and looks nice. The front already had some scratches (see photo) and i had some trouble opening the back for placing the two AAA batteries. The 0.01 gram display looks stable during weighing 
 
Below some gloves to protect my hands. I was very happy with some other gloves i used before. However after some time working in the garden holes started to appear and I could not find the same one so i decided to try this gloves from China / Aliexpress.   

maandag 17 augustus 2020

EPROM eraser (UV)

Received an UV EPROM eraser from china so i can wipe the content some old classic memory chips that i still have so i can use them in future projects.  On the top right is the on/off switch. The 'rotating knob' on the top left is a mechanical timer to set the UV exposure time.
Here a picture where you can see the bottom. I don't know what is the original idea of the hole in the little drawer. When i switch the device on i can see some of the light inside this compartment where the EPROMS need to be placed.
The device came sooner than expected. I expected an EU power plug, however that is easy to fix. The 220Volt seems, according to the description no problem.
I don't have the electronic circuit ready to program and test the EPROM chips. Also there are some other activities and projects that have more priority. However at least now i have all the components to use EPROM memory. Perhaps i can even us it with some other UV experiments.
 

donderdag 13 augustus 2020

Digital Testpen

 A week ago i received a cheap digital test-pen from china. I already mentioned in my mailbag post that i would post something about two small cheap upgrades. 

This cheap device can be used to test digital signals. it contains of a pcb with a wire as test pin and Dupont cables and comes in a sealed plastic bag. There exist several schematics to build these kind of devices yourself. However this was a cheap (almost) finished product on AliExpress.
I did two little cheap hacks to enjoy the use of this device even more. However first a photo of the back of the pcb to get a complete visual impression of the device.

As not all points always have Dupont connections i added male Dupont pins to small alligator clips. Using this alligator clips attached to the wires the testpen can also be used if no Dupont pins with power are available in the circuit you want to test. 
After soldering i even decided to remove the plastic of the male pin.
The second easy and cheap hack is using transparent heat shrink over the PCB to protect it. It can be done very easy and adds protection to the test pen pcb circuit. All you need to do is cut some transparent heat shrink tube at the appropriate size. Put it over the pcb and shrink it with a hot air gun.
If you want even more protection you can use a hot glue gun to first add a glue layer. For my use of this device i expect the heat shrink tube will be sufficient. 
Below you see the result: