Releases: eta-sys/1mul
1mul for GSM/GPRS module SIM800H v1_2
- 8 tasks
- 16 Pipes, up to 5 in each interface
- 16 Strings
- max. Pipe length 1024 Bytes
- max. String length 256 Bytes
- different interfaces count 8+1 for File System handle
- ml program up to 1024 rows, max. size 100kB
- File System up to 16 files
- 16 Timers
- 14 Digital IO
- 1 Analog Input
- 16 Variables 16-bit signed integer
- 16 Flags
- 1 PWM out
- RTClock
- 1-UART, 1-I2C, 1-SPI, 1-PWM, up to 5 GPRS-TCP/UDP Client/Servers, up to 5 GSM- Dial Voice or CSD, SMS or AT-commands Pipes
- 1 Microphone input, 1 Speaker output 4Ω/0,5W.
- SD Card interface
Console default runs on USB interface. You may use '9600,8N1' but this is not mandatory for an USB interface.
Red In/Outs 1..14 are 2,8V tolerant.
The blue terminals, as well as ADC In are 12V tolerant
Out1&Out2 (driven from pins 9, 10) are Open Collectors 300mA, up to 24V.
12V Power can be input as well as output for Power Supply.
Microphone input 'Mic' is differential self powered, so keep it away from ground.
Same situation with Speaker output 'Spc'. It can direct drive a 4Ω/0,5W Speaker.
UART port levels are 2,8V tolerant.
USB Console port needs a driver to be accessible as a PC COM port. 'http://ftp.etasys.net/SIM800_USB_DRIVER%201.1250.0/'
A SIM card with removed PIN code restriction can or can't be presented. The last one will exclude GSM/GPRS functions of the device. Removing PIN restriction from SIM card can be done using a cell-phone Security Settings.
If a SD card presents, to Create/Open a File you should use full path in format “C:\name” or “D:\name” in order to determine storage to read from. If prefix “C:\ “ omitted, in context means 'C' storage – internal Flash memory.
Examples:
Keep in mind that you always can get 'help' typing a '?' elsewhere in following functions from the Console.
Make a Voice Dial:
U1{4,1}
P1{1,CALL,”0888123456;”} #instead 'CALL' you may write 'Call' or simply 'C'
Keep in mind that Phone number string ends with ';'. After the connection establishes you can send DTMF tones using:
P1=”1234”
and read DTMF sent to you using:
$1=$P1
Make a CSD call:
U1{4,1}
P1{1,CALL,”0888123456”} #instead 'CALL' you may write 'Call' or simply 'C'
As you can see ';' in phone number is missing.
To send data use:
P1="text %X{hex data 0x1a,0x1b}...\r\n or any delimiter"
The receiving data goes to $Pipe, so you can retrieve it from there.
!$P1
To terminate a voice or CSD call simply write:
P1=0
Wait for an incoming call
Attach to GSM Unit a CALL pipe without supplying a phone number:
P1{1,CALL}
When an incoming call $Pipe contains clip of the caller, so you may decide to answer:
P1=1
or to cancel the connection:
P1=0
When an incoming call accepted and the connection established you may send data(if CSD call) or DTMF(if voice call) as per outgoing calls above.
Send a SMS Message:
U1{4,1}
P1{1,SMS,”0888123456”} #as above you can write 'Sms' or just 'S'
P1=”My test SMS\r\n”
Wait for a SMS Message:
U1{4,1}
P1{1,SMS}
?_$P1 $1=$P1,$P1=”” #check if new SMS(length > 0), if yes, read SMS to $1, then clear P1
The new received SMS contains:
sender phone number
message
date, time
GPRS handling does not differ from WiFi Pipe handling, except that you should open interface as GSM\GPRS
U1{4,2,”APN”,(optional)\"user\",\"pword\"} # if in doubt write just “GPRS” for APN
U1{4,2,”GPRS”}
AT commands
U1{4,1}
P1{1,AT}
It's essential to know that simple answers as 'OK', 'ERROR', e.t.c. are not direct passed to AT-Pipe instead the result of operation is returned as AT-Pipe value, and can be checked by reading this value:
!P1 # if = 1 then 'OK', if = 0 – 'ERROR'
For a complete list of AT commands find a 'SIM800H AT Commands manual'.
Make a record to SIM card:
P1=”AT+CPBW=1,\”08899..\”,129,\”name\”\r” # don't forget \r at the end of command
!P1
1
Read the record:
P1=”AT+CPBR=1\r”
!$P1
+CPBR: 1,”088911223344.”,129,”name”
From above answer you may extract the phone number to $1 executing:
$1=$P1](($P1/”\”,”)-2)]$P1/”,\”” # you have to escape " with \”
cut tail after “, cut leading before ,”
!$1
08899....
I2C
I2C uses fixed I/O as follows:
- 13 – SCL
- 14 – SDA
If you use I2C you should not use pins 13&14 for common I/O. You have to use own power source 2,8 V and add two 10kΩ resistors from SCL and SDA to + of power source 2,8V, as standard requires. Then you open a serial interface unit as I2C and attach a pipe to it:
U1{1,5}
P1{1,0xa0,1000}
where
0xa0 represents device address 'as is' (not moved one bit right).
1000 stays for speed = 1000 kbps (max allowed).
For device address and speed setting check your device's data sheet.
Then you can communicate with device using next:
P1="W%x{0x2a,0x00,0x01}" # Write 00,01 to register 0x2a
P1="4R%x0xfa" # read 4 Bytes from reg. 0xFA
or
P1="4R%x{0xfa}" # same meaning
As you see Read command runs some kind backward "4R%x{0xfa}" in fact says:
'send 0xfa to device('s address you already know), then R(ead) 4 Bytes'
SPI
SPI works only in 3-mode(CPOL=1, CPHA=1).
SPI pins are mapped to SD card place as follows up(near antenna) to down(near the SIM holder):
- MOSI
- MISO
- not used
-
- 2,8V
- CS (pin 15 you can see in output's list, executing 'O{?}' from Console)
- GND
- not used
- CLK
Interface Unit opens like that:
U1{1,3,0,52,8}
where:
{1, stays for 'serial'
3, type SPI
0, hardware interface number – don't care as we have just one
52 speed =52 Mbps, you may choose from 13,26 or 52
8} means bits. You may choose 8,9,16,24 or 32
If not specified default settings are ',52,8}', so you can write just:
U1{1,3}
Then attach a pipe:
P1{1,15,1}
where:
{1, goes for interface Unit 1
15, is the Chip Select pin you will use to select SPI device
1} means 'invert CS pin state', 0 = no inversion
If you have 2 SPI interfaces to same device – data and command, just open 2 Pipes to different CS pins and put a 'diode OR' from CSD to CSC on order to get CSD selected when CSC is selected.
Read/Write to SPI uses same format as I2C.
P1="W%x{0x2a,0x00,0x01}" # Write 00,01 to register 0x2a
P1="4R%x0xfa" # read 4Bytes from reg. 0xFA
If you had chosen 16 or 32 bit SPI format above, provide according data length to send.
PWM
You can use only pin 12 to output a PWM signal.
To run PWM 800Hz/50% duty write:
U1{9,2,800} # 800 Hz
P1{1}
P1=50 # % duty
P1=10 #set duty to 10%
U1{9,2,500} #set freq. to 500Hz
1mul for Pic16LF18346 with Strings
Version supports Strings and string operations. This gives the opportunity user program to receive and send data using USART. In 'Examples' you will find out how to deal with serial interface.
You may use:
- 5 tasks
- 3 Pipes in overall, up to 3 Pipes attached to one interface Unit
- 5 Strings
- max. console row capacity 60 bytes
- max. string length 40 bytes
- different interfaces count 4
- ml-program: up to 100 rows, max. size 512 bytes
- 8 Timers
- 8 Analogs
- 8 Inputs
- 8 Outputs
- 8 Variables - 16bits signed
- 8 Flags
- up to 3 channel PWM
- RTClock with day of week calculator.
I/O/A pins you may use 3,5,6,7,8,9,10,11,12,13,14,15,16,17.
pin 2 dedicated for LED, connected to Vdd in series with 1k resistor.
pin 4 MCLR, so connect to Vdd for work.
pin 18 Serial Rx
pin 19 Serial Tx
pin 17 RS485 Rx/Tx switch
Console runs 9600, 8N1, CR+LF.
When uploading ml program use 'Send file line by line' option from 'Send File' menu of 'MySerial'.
1mul for Pic16F628A
With its 2k program memory and 128 bytes Flash this Pic offers not much from mul. Nevertheless I managed to run several gadgets on it.
Resources available to user:
- one task. J0 uses Console and J1 available to user.
- ml-program may contain max. 8 rows, max. 46 symbols per row, and overall size less than 128 bytes!
- RS in message max. 48 bytes long
- 4 Timers
- 8 Var's
- no Analogs
- 8 Flags
- 8 In's
- 8 Out's
- no strings, no pipes
- no RTClock
- all arithmetic and logic operations over 16 bit numbers
I/O pins you may use 1,2,6,9,10,11,12,13,15,16,17,18.
pin 3 dedicared for LED connected in series with 1k resistor to Vdd.
pin 4 MCLR connect to Vdd for work.
pin 7 Serial Rx.
pin 8 Serial Tx.
Console runs 9600, 8N1 with CR+LF delimiter. For download of ml program use 'Send row by row' option from 'Send File' menu in 'MySerial'.
Next picture shows processor's pin map on demo board
mul written in Assembler using MPLAB IDE v8.92.
1mul for ESP8266
A complete version for ESP8266
- 8 tasks
- 16 Pipes in overall, up to 5 Pipes attached to one interface Unit
- max. string length 256 bytes
- max. pipe's buffers length 512 bytes
- different interfaces count 8+1 for file system (FS)
- ml-program: up to 1024 rows, max. size up to 64k
- file system up to 16 files
- 16 Timers
- 16 Analogs
- 16 Inputs
- 16 Outputs
- 16 Variables - 16bits signed
- 16 Flags
- up to 5 USART pipes
- up to 5 TCP, UDP Client/Servers
- AP and Station work
- up to 5 channel PWM
- one analog input
- RTClock with day of week calculator.
Console runs 9600, 8N1, CR+LF.
When uploading ml program use 'Send file' option from 'Send File' menu of 'MySerial'.
Processor's pin map follows:
Project developed in Eclipse Espressif/ESP8266 SDK 13.0.
To use ADC change byte 107 in Esprssif>ESP8266_SDK>bin>esp_init_data_default.bin to 0x21 (33 dec) as described in SDK APP NOTES.
If you intend to use M-command (forcing ESP to sleep for a while) connect GPIO16 to RST pin.