Category: Uncategorized


DWIN HMI Touch Displays can be used as MODBUS RS485 MASTER.

PYMODSLAVE simulator software is used in this demo as Modbus slave.

Modbus is protocol and RS485 is physical electrical media for data transmission. It is industry standard and can run up to maximum 1000 meters length. Compared to RS232 it is less prone to noise.

In this demo we have 3 background images. Note the naming of images start from 00.jpg.

DWIN Display used here is 5-inch 800 x 480 resolution capacitive touch model. Background images are matched to this resolution. Using ICL tool we first create 32.icl file for background images and save it inside DWIN_SET folder of the project.

In the first image 00.jpg we define some VP address locations for Analog Input and Analog Output values.

The Modbus command to Read Analog Input is 0x04. We define 3 locations as DATA VARIABLES with VP address 2000, 2001 & 2002.

For Reading Holding Registers AO , command is 0x03 and 2 VP address as DATA VARIABLES 2200 & 2201.

To WRITE Single Holding Register AO , command is 0x06 and we use data variable with VP 2500.

A keyboard pop up is used to feed in the value.

For writing to multiple registers , the command is 0x10 and VP address we use 2600, 2601 & 2602 , all contiguous.

For keyboard pop up we use VARIABLE INPUT from Touch Control menu over the Data varibale.

The VP address for Data INput must be same as that of Data Variabel.

For command 0x06 the VP used is 2500.

For command 0x10 VP used is 2600, 2601 & 2602.

Page 3 is 02.jpg and here we have a KEYBOARD .The elements of keyboard are defined using BASIC TOUCH module and respective key code HEX values are provided.For e.g no. 1 hex value is 0x0031, 2 is 0x0032 , etc as given in the note below.

Here is the KEYBOARD pop up configuration.

VP address is same as Data variable.

Data uploading is Enabled. Variable type is INTEGER 8 digits.

Font ID is 0 and font size is set to 20.

Cursor color is set to White. Display method is Direct Display , which means we can see what we type.

Keyboard location is set to OTHER PAGE.

Now click on Keyboard setting. Select the 02.jpg image where we have configured keyboard.

Select the area of display of Keyboard and click OK.

Now you can see the page id as 2 and keyboard area coordinates..

Against Show location click on SET.

Click on any area of image .This is to select the coordinate for left top area of keyboard. click OK.

Now the Show location coordinates are set.

Enable limits is optional. If required you can provide the minimum and maximum values that keyboard can input.

Scroll up to another show location on top and click SET.

Enable the Display Keyboard.

Keyboard is displayed on screen. Now click a dot on the keyboard area where numbers will be displayed.

Save the project.

Under Display , click on Preview from Current page.

You can preview your project. Click on AO 0x06 command location. A keyboard pops up. Feed in some value, which appears at the VP location.

Double click preview window border to close preview.

Same way you can implement keyboard pop up for VP 2600, 2601 & 2602.

Copy and paste the Data input over the new VP and just change the VP address.

Next page is 01.jpg.Here we define VP address locations for slave 3.

To READ DISCRETE Output Coil command is 0x01.

Read Discrete Input Contact 0x02

Write Single Discrete Coil is 0x05. Write Multiple Coils command is not yet implemented in DWIN.

VP address locations to be defined as per BIT AREA 1 and 2 .

As Read and Write Coils are BIT oriented ( 1 AND 0) , DWIN has 2 BIT areas.

AREA 1 is from 0x100 to 0x10F

AREA 2 is from 0x110 TO 0X11F.

And we have to provide the command in 22_Config.bin file atarting location 0x1C000.

The VP address location to be used in config file is as per table below.

For e.g AREA 1 , if we use VP as 0x101 , then we have to use vp as 0010 in config file.

Now in page 2, 01.jpg we will define the VP address locations as per table .

For Reading Discrete Output Coil we use BIT ICONs.

VP address we use from AREA 1 , 0X101.

Under Biticon ON OFF click on SETTING.

Select the BIT POSITION.

FOR FIRST ICON BIT POSITION SELECTED IS 0.

Icon file is selected as 42.icl.

ICON0S and ICON1S are used.

Click on the + symbol.

Select the icon for 0S and then for 1S. (OFF icon and ON icon).

Same way select the bit 1 for next bit icon

Bit 2 for the 3rd , Bit3 for the 4th biticon.VP remains the same 0x101.

For Reading Discrete input contact we use BITICON and now we use VP 0X102 from AREA 1.

Bit settings done for bit 0 and bit 1.

For Writing Single Discrete Coil , we must use VP from AREA 2..

Bit ICON is used and VP we select from AREA 2 as 0X110.

Bit setting is done as 0, 1 and 2 for the 3 Bit icons.

As we have to Write to Slave we implement Incremental Adjustment over these 3 Bit icons for Write Coil.

Incremental ADj VP is same as Bit icon 0x0110.

Respective BIT position is selected as 0, 1 & 2.

Adjustment method is ++.

Overlimit operation is Cycle , Adj step length is 1.

Lower limit 0 and upper limit 1.

Click save project and then GENERATE.

Inside DWIN_SET folder you can see the .bin files generated.

Add 0.HZK file for fonts.

Most important is the OS bin file. From official website download the Kernel files for MODBUS Master.

Download link here

Select the correct bin file.Here we use baud rate 9600 and our 5 inch model supports RS485 at UART5.

So we have copied and pasted the correct OS bin file.

SAS

0.HZK font file can be generated from under the Welcome screen.

The 22_Config file to be copied and pasted outside DWIN_SET folder.This file has to be modified for commands at location starting 0x1C000 and placed back to DWIN_SET folder .Finally this DWIN_SET folder is downloaded to DWIN HMI using SD card method.

To edit 22_Config file , we use PSPAD Hex editor.

http://www.pspad.com/en/download.php

open the 22_Config.bin file with PSPAD Hex editor and go to location 0x1C000

where the Modbus instruction command starts.

The first command is

5A02 0403 5001 0000 2000 0064

D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11

D0 : 5A Execute this Instruction
D1 : SLAVE ID (here it is 02)
D2 : Command 0x01,0x02,0x03,0x04,0x05,0x06,0x10 (04 is used here)
D3: Length of Data in word (03 means 3 word or VP address locations)
D4 : Receive Time out 2 -255 msec ( 50 msec used here)

D5 : Command Execute Mode 00 – 04 ( 01 mode means , next 2 bytes mention the page id)
0x00=Execute unconditionally.
0x01=Execute under the page specified by D6.D7.
0x02=Execute when the key value specified by D6.D7 is non-zero,
and the key value will be cleared after the command is executed.
0X03=In the 0x06 command, when the value of the variable
pointed to by D 8 .D 9 is non-zero, it will be sent automatically.

D6.D7: When D5=00, no configuration is required.
When D5=01, the configuration is page number (0002).
When D5=02, it is configured as the key address for trigger sending.
When D5=03, no configuration is required.
When D5=04, no configuration is required.0

D8.D9: This command operates the source variable address ( VP 2000 used here)
or starting address ( 1000H) allocated in the DGUS screen .
D10.D11: The slave address point table (0x0064 = decimal 100 ) operated by this instruction.
D12.D13.D14.D15: Undefined.

The second instruction is

5A02 0302 5001 0000 2000 006E

5A is start instruction and 02 is SLAVE ID.

03 is command to READ HOLDING Registers , following 02 means 2 words or 2 VP address locations

50 is 50 msec timeout

00 is mode , which means applicable on all pages .Following 2 bytes are 0000 when mode is 00.

2000 is the starting VP address

006E is slave address decimal equal to 110.

Copy this 22_Config.bin file and paste it to DWIN_SET folder.

Already we have stored the correct OS file for 9600 baud UART5 Modbus Master.

Save this DWIN_SET folder to the SD card.Note that maximum 16GB card is supported and it has to be formatted as FAT32 file system and allocation units 4096 bytes.

Plug the SD card on to DWIN and power on.

Blue download screen appears.

When download is completed , remove power and then remove SD card.

Now if you power up DWIN , you can see the project images on screen.

Next we shall connect the display to PC using an USB-RS485 converter. A B pins of DWIN is configured for RS485 communication at baud 9600.

The RS485-USB device used here is built on CP2102 driver.On connecting to PC a COM port is allotted.Here it is COM8 .Note it down.

pyModSlave software is downloaded from link :

https://sourceforge.net/projects/pymodslave/files/latest/download

Open the pyModSlave software .Click options –> Modbus RTU

Set the serial port as COM8 , as that of USB-RS485 and baud rate 9600.

Slave address is set to 2 and Start address 100 (hex 0x064) which is used in the instruction command in 22_Config.bin file.

Click Connect.

Select AI Input Registers & Type in some values at address 100, 101 ,102.

These values appear on the DWIN display at the VP address as per the instruction command.

Now select AO – Holding Registers and type in some values at address 110, 111.

These values appear at DWIN VP locations.

Next is the command instruction to write Holding Registers.

For this , instruction command to be stored in 22_Config.bin file

5A02 0601 5000 0000 2500 0078

5A02 1003 5000 0000 2600 0082

06 is the command to Write Single Holding Register.

10 is the command to Write Multiple Holding Registers.

Include this 22.bin file within DWIN_SET folder and download it to hardware.

From DWIN display touch on the Write single Register VP location. A Keyboard pops up as per design.

Feed in some value.

Same way feed in some values at Multiple Write VP locations.

On PyMod slave select AO Holding Registers.

At decimal address location 120 and 130 you can see the values entered on DWIN.

Next we shall feed in the command instructions for page 2 .We will use SLAVE ID 3.

DD

dd

FF

EE

SS

DD

SS

SS

SS

AA

SS

DD

DD

SS

DD

AA

DWIN HMI display can be configured to be used as a MODBUS Slave. Step by Step configuring is explained in this post.

To start with, collect the background images that matches the resolution of your hardware. Here we have a 5-inch industrial grade display of 800 x 480 resolution. It has A B pins at UART5 , where we implement RS485. Power source required is 12v 2 amp.

A RS485-USB device is needed for Modbus communication. A is connected to A of DWIN and B to B.

A com port is allotted to this device through which communication happens.

From the official website, download the MODBUS SLAVE files. Select the one that matches your requirements. We are using here 115200 baud, UART 5 file. Select the OS bin file and paste it inside the DWIN_SET project folder.

https://www.dwin-global.com/uploads/Slave1.zip

We have 3 background images in this project.Note the naming of images starts from 0.

0 page is for testing READ commands from Master.Commands tested are

0x03 Holding Register

0x04 Input Registers

Page 1 is for testing WRITE Commands from Master.

0x06 Single Register

0x10 Multiple Registers

Coils Read/Write can be tested only from a physical PLC Master and not from a simulator software.

page 2 has a keyboard. Here we implement Basic Touch over the keys with Hex values. Pop up keyboard implementation you can refer our previous video here :

Back ground images in folder 32

Icons in folder 42.

You need to generate .ICL files for images and icons using the ICL tool and save as 32.icl & 42.icl under DWIN_SET folder.

Inside DWIN_SET folder you have the .icl files, UART5 bin OS file and the .HZK file for fonts.

In the first page of design we have a background image 0.jpg.

From ICON display , BIT ICON is selected and we provide a VP address 0x1100 .

Bit icon setting enabled for LSB bit.

ICON0S & ICON1S selected from 42.icl for OFF and ON icons.

For Touch effect we use INCREMENTAL ADJ over the BIT ICON and the VP must be same 1100.

Bit number is set as 0.

Adjustment method ++ ,

step length : 1, Lower limit : 0, Upper limit : 1, Touch effect : Disposable

Next we add a Data Variable with VP 1200. Variable type as Integer 2 bytes.

Over this we add a Data Input from Touch and configure the pop up keyboard. VP is same as Data variable 0x1200.

Pop up key board is in image 2.jpg.

Using Basic Touch all digits are configured with respective Hex values.

For testing 0x04 command Input Registers we use 3 Data varibles with contiguous VP address starting 0x1300 , 1301 & 1302.

For Data input using pop up keyboard we implement Data Input from touch over these 3 Data varible locations.

Finally in the image 01.jpg for WRITE Commands from Master , we use Data variable with VP address 2000 and a Variable icon with VP 2050.

This is to test 0x06 Write Single Register from Master.

QMODMASTER freeware open source is used as Master Simulator :

https://sourceforge.net/projects/qmodmaster/

Open QMODMASTER software Master simulator.

Click on Options –> Modbus RTU

Select the COM port allotted to the RS485-USB device.

Baud Rate is 115200 ,as we have downloaded the 115200 OS to DWIN.

Data bits 8 , No Parity , 1 Stop bit.

From Options –> Settings

Ensure that Base Address is 0

Response timeout minimum 1 sec and Big Endian.

Modbus Mode is RTU , Slave Address is 1 , Scan Rate is 1000 msec.

Select from drop down , the Function Code as 0x03 which is for READ HOLDING REGISTERS.

VP address is 1100 HEX.

As this Master software allows address entry in HEX , it is easier to enter the VP address of DWIN directly.

Set the Number of Registers to 1 , as we Read from one Register address of DWIN 0x1100.

From Commands click on CONNECT to establish MODBUS communication.

From DWIN touch the vp location 1100 to ON icon.

You must click Commands –> Read/Write to execute.

Now you can see the ON value 1 .

Now change the icon back to OFF on DWIN.

Click Read/Write Command.

The data changes to 0.

Next , change the START ADDRESS to 0x1200

Function code is 0x03.

From Dwin touch on the vp location 0x1200. A keyboard pops up , as per the project design.

Key in any data value and press ok.

On QMODMASTER click Read/Write command to see the value set at vp 1200.

At VP location starting 0x1300 we have 3 Data variable locations in DWIN.

Feed in some decimal values using the pop up keyboard.

In Master , set the Function code as 0x04 READ INPUT REGISTERS.

Start address as 0x1300 and number of Registers as 4.

Click Read/Write command to get the values from DWIN .

Next set the Function code as 0x06 WRITE SINGLE REGISTER.

VP as 0x2000.

Feed in a value at this single register in Master.

Click Read/Write.

The decimal data from Master will appear at DWIN vp address 0x2000.

Change address to 0x2050 and feed in a value 1.

Click Read/Write to see the icon change from OFF to ON at VP 0x2050.

Change the address to 0x2100 and set the number of Registers to 3.

Feed in some values at this 3 register locations of Master.

Click Read/Write to get the data on DWIN Slave.

Video Demo :

https://www.alselectro.in/copy-of-raspberry-pi-displays

The BTS7960 is a high-current full-bridge motor driver module. The Key features are:

  • Input voltage: 6V to 27V
  • Maximum allowable current: 43 A
  • PWM capability: up to 25 kHz
  • Two PWM output pins for speed control in direct and reverse directions
  • Two EN output pins to control motors
  • Two IS input pins to protect against high current and heat

BTS7960 is a fully integrated high current half bridge for motor drive applications.
This contains one P- channel high side MOSFET and one N channel low side MOSFET with
an integrated driver IC in one package.

This module can be used to drive  2 wire huge current Motors .Not suitable for Stepper Motors .

In this post we will be using a huge current Motor 24v 250Watts like this :

A separate power source is required for this Motor.

24v 10Amp Metal SMPS is used for this source

This module has 12 pins:

Microcontroller pins (Low current):

  • VCC: Module power supply – 5V
  • GND: Ground
  • IS-R: Input signal for detecting high current – Straight rotation
  • IS-L: Input signal for detecting high current – Inverse rotation
  • EN-R: PWM Signal for controlling motor speed – Straight rotation
  • EN-L: PWM Signal for controlling motor speed – Inverse rotation
  • PWM-R: for controlling motor RIGHT direction
  • PWM-L:  for controlling motor LEFT direction. 

Motor pins (High current):

  • M+: Motor Positive
  • M-: Motor negative
  • B+: Battery positive
  • B+: Battery negative
  • You cannot overload the BTN7960B to destruction. It will overheat and safely shut off. Then restart when it cools and the Enable line is pulsed low then high . Under voltage Shut Down: To avoid uncontrolled motion of the driven motor at low voltages the device shuts off . If the Supply voltage  drops below 5.4V , The Motor driver will switched Off , And won’t turned on untill the Supply voltage increased to 5.5V Or more .
  •  Over temperature Protection: The BTS 7960 is protected against over temperature by an integrated temperature sensor. Over temperature leads to a shut down of both output stages.
  • Current Limitation : The current in the bridge is measured in both switches, High and Low side.If the current reaching the limit current  the switch is deactivated and the other switch is activated for a certain time.
  • To get the Motor to move in an H-bridge the Enable inputs should be held high and PWM-A and PWM-B should be different polarity.
  • Don’t pulse the enables and hold the PWM inputs at a DC level. Some old driver chips can do this. The BTN7960B doesn’t work that way.
  • The naming convention is bit confusing.
  • R PWM & L PWM pins can be pulled HIGH or LOW to enable Direction of Rotation.
  • R-EN  & L-EN pins are used for speed control using PWM.Generally , these 2 pins are connected together to a PWM pin of Arduino. AnalogWrite command is used to control speed.

Connect the Motor red wire to M+ and black wire to M-.

Connect B+ of module to positive of 24v 10amp power source . B- to negative of SMPS.

Make use of thick copper wires for power connection as the motor takes high current.

The module has  8 control pins.

Vcc is connected to 5v of Arduino & Gnd to Gnd of Arduino.

R_IS & L_IS are for current limit alarm outputs, which are not used in this demo.

R_EN & L_EN ins are Right,Left speed control pins .Both are connected together to D11 of Arduino. Note that we use a PWM enabled pin of Arduino for this.

L_PWM is connected to D10 ,  R_PWM is connected to D9. These 2 pins decide the direction control of the motor.

Now upload the following code to Arduino.

To run the motor in CW direction we make R_PWM pin High and L_PWM pin Low.

To make the motor run in CCW –   R_PWM pin Low and L_PWM pin HIGH.

To stop the motor both pins are made LOW.

Speed is controlled using ANALOGWRITE function where the PWM pin is given a value from 0 to 255.

——————–

#define RPWM 9
#define LPWM 10
#define PWM 11

void motor_cw(){              //CLOCK WISE
  digitalWrite (LPWM, LOW);
  digitalWrite (RPWM, HIGH);
  analogWrite (PWM, 255); // 0- 255  
  Serial.println (“MOTOR RUNS CW”);
  }
void motor_ccw(){              //ANTI CLOCK WISE
  digitalWrite (LPWM, HIGH);
  digitalWrite (RPWM, LOW);
  analogWrite (PWM, 255);
  Serial.println (“MOTOR RUNS CCW”);
  }

void motor_stop(){          //motor stop
  digitalWrite (LPWM, LOW);
  digitalWrite (RPWM, LOW);
  analogWrite (PWM, 0);
  Serial.println (“STOP”);
  }
 
void setup() {
Serial.begin(9600);
Serial.println(“START”);
pinMode (RPWM, OUTPUT);
pinMode (PWM, OUTPUT);
pinMode (LPWM, OUTPUT);
}

void loop()
{
delay(2000);
motor_cw();

delay(5000);
motor_stop();

delay(5000);
motor_ccw();
}


 

Image 4

 

In these days of Virus spread , automatic hand sanitizer and auto water tap are the need of the hour.

This is a very simple and low cost effective circuit without a Microcontroller.

Water pump or Water Solenoid can be controlled for dispensing sanitizer or water automatically when hand is brought near the sensor.

Sensor used here is an IR MODULE.

Image 3

 

The IR sensor module is built on  IR Transmitter and Receiver, Opamp, Variable Resistor &  output LED indicator. IR LED Transmitter is white or transparent in colour,and emits infra red light invisible to human eye.IR Receiver is a photo diode black in color to absorb more light.

IR rays reflected from object is sensed by this receiver and current flow is proportional to the amount of Light. This property makes it useful for IR detection.

A LM358 or 386 comparator is on board and gives a LOW signal while detecting IR.

Normally Output pin is HIGH and becomes LOW on any intruder object.The blue trimpot can be adjusted for sensitivity.

The board operates on 5V DC , and we need a 7805 regulator to convert 12v to 5v.

Image 2

 

The main device in the circuit is the 4 leg IC OPTOCOUPLER PC817.

It is the cheapest IC available and price is less than a 555 IC.

images

It has inbuilt  Infrared Emitting Diode (IR LED) and a photo transistor . It is Enclosed in a 4 pin package.

The photo transistor’s base becomes activated when LED conducts and throws light on it. When the current flowing through the LED is interrupted, the infra-red emitted light is cut-off, causing the photo-transistor to cease conducting. The photo-transistor can be used to switch current in the output circuit.

The black DOT is pin 1 which is ANODE of Diode.

PC817-Internal-Pins

The output of OPTO drives a Transistor and in turn the solenoid.

The transistor we use is a NPN  BD139.

 

Image 7

  • Continuous Collector current (IC) is 1.5A
  • Collector-Emitter voltage (VCE) is 80 V
  • Collector-Base voltage (VCB) is 80V
  • Emitter Base Breakdown Voltage (VBE) is 5V
  • DC current gain (hfe) is 40 to 160

To the collector of BD139 is added the load (solenoid or water pump) through supply voltage.

When BD139 conducts , it switches ON the solenoid.

A diode 1n4007 is used across the coil of solenoid.

A    FLY BACK Diode is placed with reverse polarity from the power supply and in parallel to the relay’s inductance coil. The use of a diode in a relay circuit prevents huge voltage spikes from arising when the power supply is disconnected. A flyback diode is sometimes called flywheel diode, relay diode, or snubber diode as a flyback diode circuit is a type of snubber circuit.

The solenoid used for water tap is the one widely used in water coolers.

Normal working voltage is 24v DC , but it works fine on 12v.

Image 5

 

The valve features a solenoid, which is an electric coil with a movable ferromagnetic core (plunger) in its center. In the rest position, the plunger closes off a small passage. An electric current through the coil creates a magnetic field. The magnetic field exerts an upwards force on the plunger opening the passage.

This is the basic principle that is used to open and close solenoid valves.

The hole size of 1/4 , 1/2 inches available.

Smaller size ones used for sanitizer dispenser and the bigger ones for water tap.

Instead of solenoid you can replace with a pump motor also.

Image 6

This is a low cost, small size Submersible Pump Motor which can be operated from a 2.5 ~ 6V power supply. It can take up to 120 liters per hour with very low current consumption of 220mA. Just connect tube pipe to the motor outlet, submerge it in water and power it. Make sure that the water level is always higher than the motor. Dry run may damage the motor due to heating and it will also produce noise.

The final circuit requires a 12v supply .

The IR module used here is sensitive to Sun Light.So always cover the IR LEDs with a black sleeve or tape and adjust sensitivity by turning the blue trimpot.

When hand is brought near the IR circuit , it sends a LOW signal to OPTO coupler.

This conducts the BD139 and in turn operates the solenoid or pump.

 

IMG_20200505_171041

 

VIDEO :

blog_image

The mini OLED 0.96 in display is 128 x 64 pixels and communication protocol is I2C.

There is also a SPI version which has more pins 6 or 7.

The I2C model has only 4 pins Vcc,Gnd,SCL & SDA.

The supply volt is 3.3 to 5v. As an I2C device it has got an address , by default it is 0x3C or decimal 60. This can be changed by soldering the position of a resistor on the back of pcb.

 

ol3

Connect Vcc of OLED to 3.3v, Gnd to Gnd

SCL  –>  GPIO 22

SDA  –> GPIO 21

IMG_20200328_140033

Resolution of display is 128 x 64 pixels. 0 to 127 in X axis and 0 –63 on Y axis.

oled_pix

 

MicroPython provides some built-in support for these displays, and a simple framebuffer which can be used as a drawing surface.

However, we still need a driver to interface the buffer to the display.

There is a Python ssd1306 module for OLED displays available.This is python library for interfacing OLED (both I2C & SPI supported).

https://github.com/micropython/micropython/blob/master/drivers/display/ssd1306.py

Click on Raw button and save as ssd1306.py file on your computer.This save as appears only in Chrome browser.

Open THONNY PYTHON

Use File  –> Open and browse to the location to select the ssd1306.py file.

Click File  –>  Save as

Select Micropython device (ESP32)

 

o1

Save the file as ssd1306.py

Now the driver module is on ESP32.

o2

By default already you have boot.py

Now we have loaded the driver ssd1306.py.

o3

From interpreter of Thonny Python , the individual code can be tested.

From machine module import Pin , I2C

Pin Class handles all GPIO pins and I2C handles i2c protocol..

Then import the OLED driver module ssd1306.

 

o4

To use the display you first need to create an I2C interface. In MicroPython I2C is  via a software implementation so you can select any GPIO pins you like.

We shall select the default SCL pin GPIO 22 &  SDA pin GPIO 21.

 

o5

 

Then create an oled object from class SSD1306_I2C

as this class is inside file ssd1306, we use

ssd1306.SSD1306_I2C

The arguments are  128 – width , 64 – height , i2c – protocol, 0x3c – address

 

o6

 

Once the object is instantiated , the methods can be used.

.text() method is to print message on display.

Pass on the message to print and the X,Y coordinates.

.show() method is used to show the message from buffer to display.

Unless you issue this oled.show() , you cannot see the result.

 

o7

 

The framebuffer class provides support for writing text using a simple 8×8 bitmap font. The pixel x,y positions are relative to the top-left of the 8×8 character, so positioning at 0,0 will give the absolute top left of the screen.

Here we have selected x= 30, y =30 POSITION.

 

IMG_20200330_055934

 

To CLEAR the display we call   fill ( 0) method an then show()

 

o8

 

To draw an illuminated  line. Origin  Origin (10,10) and final (80,20)

For illuminated , we use 1 at end

o9

 

IMG_20200330_060216

 

Draw an illuminated horizontal line. Origin (5, 30) width 100 pixels

o10

 

IMG_20200330_060410

Draw an illuminated filled rectangle. Origin (20,10) and width x height 60×40 pixels

o11

 

IMG_20200330_060526

 

 

The ssd1306 object itself  provides methods for direct control of the display component.

The display can be turned on and off using

oled.poweron() and oled.poweroff() respectively.

o13

 

You can set the contrast for the display using

.contrast() passing in parameter c which is a value between 0 and 255. This controls the contrast between the foreground, active colour 1 and the background 0.

o14

To invert the display, switching foreground and background colours, call .invert(1).

Calling .invert(0) will return the display to how it was originally. You can use this for display-flashing visual effects:

o15

Download code and library module from here :

http://www.alselectro.com/files/micropython_oled_dht_ultrasonic.zip

After testing OLED using interpreter , we shall write code on to EDITOR of Thonny Python.

ol1

Save this file as main.py on Micro Python device.

Now you have 3 files on ESP32

boot.py

main.py

ssd1306.py

ol2

 

Micropython executes boot.py on power on , then looks for main.py to execute.

Click on F5 to execute and see the result on OLED display.

Video :

 

 

blog_image

Check out my previous posts on WIFI ESP8266 1.AT COMMANDS  ,  2. TCP CLIENT/SERVER

In this post we shall see how to connect ESP module with an ANDROID Mobile device & communicate.

On ESP side following are the AT commands to configure :

AT+CWLAP   –  Lists all surrounding Access Points

AT+CWJAP = “SSID”,”password”     – Join with your preferred AP

AT+CWMODE=1       ESP on STATION Mode

AT+CIPMUX=1     Allow multiple connections

AT+CIPSERVER=1,80   start the SERVER on port 80

AT+CIFSR    to get the STATION IP Address

 

Image127

On your Android Mobile open SETTINGS & switch ON WI FI

 

DSC00139

 

Surrounding Access Points will be listed automatically.Select the one to which the ESP module has joined already.Here it is MBLAZE , which is a secured one.

 

DSC00140

 

Open the preferred WIFI access point & connect to it by providing the Password.

 

DSC00143

Now , my Mobile has connected to the Access point where ESP is already connected with.

 

DSC00145

 

From the Market , install a TELNET client on your Mobile

Image118

 

Open the TELNET Client

TELNET waits to get the Local Host IP & the Port number.

DSC00149

 

Enter the IP as 192.168.1.2 & Port as 80  .

This IP is the one we got from AT+CIFSR previously & we’ve started a Server on port 80 already with ESP.

Touch on Connect to Server

DSC00150

Now the TELNET Client is connected to the ESP server on port 80.

Type in some characters & touch Enter

 

DSC00153

 

The characters are received by the ESP Module

Image125

 

To send data to TELNET ,use the AT command

AT+CIPSEND=0,15

This command is to send 15 characters on channel 0

 

Image126

 

The message is received by the TELNET screen.

 

DSC00156

 

 

 

cooltext753793315

 

First time in India , VEGA ROBOKITS has engineered a development board universal to both AVR & 8051 ICs.The board has in built Programmer capable of programming both AVR & 8051 family ICs.

 

board2

 

A 40 pin ZIF socket is used as Target to hold the 8051 IC. Additional 40 pin ZIF socket with modified connection is provided to host AVR ICs.This additional ZIF socket should be placed over the on- board ZIF socket to use AVR ICs.

 

 

image4

 

board1

 

8051 PROGRAMMER & DEVELOPMENT

To start with we shall see how to use this board for 8051 development.

Select switch 1 to USB position ,if you connect the board to PC using A to B USB cable.Now the power is taken from USB itself. If this switch is selected to other side , the board needs an external 12v/1A adapter.

Select the ISP switch (switch 2 near the middle of board) to ON position.This makes sure that you’re going to program the chip .

Put the jumper (found on top of I2C EEPROM IC) on 8051 position.

 

WILPRO’s WLAR software is used as an application to fuse the HEX files.Download the zip file from :

http://www.alselectro.com/files/wlpro_v220_setup.rar

No installation is required.It is a standalone application.

Download the drivers required for this board from :

http://www.prolific.com.tw/UserFiles/files/PL2303_Prolific_DriverInstaller_v1_10_0_20140925.zip

Unzip the driver file & double click on  “PL2303_Prolific_DriverInstaller_v1.10.0 “  EXE file to install the drivers.

Connect the USB cable of board to PC & open the DEVICE MANAGER.

If the PORT allotted is within range 1 to 9 , you can start the WLPRO application and proceed to load HEX file.

If the port allotted is a double digit , then WLPRO will enter DEMO mode .Only in ON LINE Mode you can load the HEX file.

 

g1

 

To solve this , RIGHT CLICK on the port allotted inside Device Manager & select PROPERTIES.

Under PROPERTIES window select PORT SETTINGS

 

g2

Click on ADVANCED button under PORT SETTINGS.

 

     g3

From the DROP DOWN you can select a PORT number between 1 & 9  &  click OK.

If the port number is not free , you can try overwriting the pre allotted port number & confirm.

 

g4

 

g6

 

g5

 

After PORT setting to single digit  , open the WILLAR software . Now you can see ONLINE MODE at the bottom of screen.

 

g7

Click on DEVICE button & select the target device as AT89S51@ISP 

If you select plain AT89S51 , DEVICE ID ERROR will be returned while programming .So make sure to select the ISP version as device.

Image 6

Click on LOAD button & browse to the location of the HEX file to be fused.Select the HEX file & then click OPEN.

 

g9

 

On the next LOAD FILE window leave the File type as “INTEL HEX” & CLICK ok.

g10

 

You’ll see LOAD FILE SUCCESSFUL display.

Image 7

 

Now click on the PROGRAM button on the left pane.

prog1

 

Programming is DONE & you get Program Successful display.

Image 8

 

If you click the AUTO mode button , all functions like Erase,Blank check ,Program,Verify & code copy Protect will be done automatically one by one.

Image 9

To test the program loaded , change the switch 2 to ISP OFF position .Push RESET button to see the result of blinking LED .

 

AVR PROGRAMMER &DEVELOPMENT

 

Select USB ON (switch 1)

Select the ISP (switch2) to ON position.

Put the Jumper on top of I2C chip to AVR position.

Place the converter socket on the ZIF socket & lock it.Make sure that the handles of sockets match.Do not place the socket in REVERSE as it may damage the target IC.

 

Image 15

On WILLAR IDE select the DEVICE as ATMEGA16L@ISP 

Ensure to select ISP version of IC & not the plain one.

Image 11

 

Select File type as INTEL HEX & click OK.

 

Image 12

 

Click on LOAD & browse to the location of AVR HEX file .

Click OPEN to LOAD the file.

Image 13

 

After LOAD SUCCESSFUL display click on PROGRAM to fuse the file.

 

Image 14

 

Watch this support video  :

 

8051 / AVR UNIVERSAL DEVELOPMENT BOARD WITH PROGRAMMER

For availability of this board contact :  

 

http://www.alselectro.com/8051_avr-2-in-1-development-board-with-programmer-.html

 

cooltext753793315   cooltext753790696

2014 in review

The WordPress.com stats helper monkeys prepared a 2014 annual report for this blog.

Here’s an excerpt:

Madison Square Garden can seat 20,000 people for a concert. This blog was viewed about 67,000 times in 2014. If it were a concert at Madison Square Garden, it would take about 3 sold-out performances for that many people to see it.

Click here to see the complete report.

Previous post Minipro 866 CS

In this post we shall review the second model of MINIPRO UNIVERSAL PROGRAMMER .This is same as the 866CS model but has the ability to program “IN CIRCUIT”. ICSP programming involves programming the chip leaving it on the existing board itself.This saves the hard work of removing the chip from board and again fixing it.

We shall see how to program PIC16F877A leaving the target IC on the demo board itself.The ZIF socket on programmer is not used & ICSP connector is used instead.

Open the MINIPRO IDE & select the target IC as PIC16F877A.

clip_image002

Instead of 40P Adapter selection (which is default) we’ll select the ICSP port seen under “Set Interface” & ensure that ICSP VCC is Enabled.If this is not enabled then a separate power source is needed for the target demo board.

Click on OK.

clip_image004

Now click on the INFORMATION button seen at the right top corner.

This will display the ICSP connection details between the programmer & the target board.

As the readymade wire supplied with the programmer may not match with all target boards , it is better to use separate wires.Here our target board has male berg pins.So Female to Female Jumper wires are used for the connections.

clip_image006

No separate power source is required for the target demo board as we’ve selected ICSP_VCC Enable.

clip_image008

To load the HEX file on to the buffer click File à Open & browse to the HEX file location.

clip_image010

clip_image012

Confirm that INTEL HEX is selected under File Format of File load Options & All Memory selected under To Region

clip_image014

Now click OK to see the HEX file loaded to the buffer .

clip_image016

 

  Click the P button on top to initiate Programming

.clip_image018

Finally click on the Program button.

clip_image020

You can see the Programming Progressive bar.

clip_image022

Finally PROGRAMMING SUCCESSFUL message appears.

clip_image024

 

For Programming ATMEL 89Sxx ICs the procedure is same as above.The ICSP connections are known by clicking the INFORMATION button .

clip_image026

Once the connections are done as per the diagram , the HEX file developed using KEIL can be loaded on the buffer.Then Program can be done.

For AVR ICs following is the ICSP connection detail

clip_image030

 

MINIPRO 866A is a must have tool for all Embedded enthusiasts and Lap Top service Engineers.

The huge support of IC list and ICSP functionality makes it the most value for money product.Note that other manufacturers offer these support for a cost of around Rs.25000/- while the cost of MINIPRO 866A is around 5500/- & if you do not need ICSP ,it is only Rs.4500/- (866CS model).

Watch this support video :

All these days I’ve been using the classic Windows Movie Maker for producing tutorial videos.Recently I purchased this CYBERLINK POWER DIRECTOR 13 for creating videos.This is the first video created using power director.You can leave the comments on the video.

 

MINIPRO 866A ICSP UNIVERSAL PROGRAMMER

For availability contact :

cooltext753793315 cooltext753790696

In a previous post we’ve seen a Universal Programmer TOPWIN which is capable of programming 8051,PIC,AVR,EEPROM ,EPROM,etc.. But the main problem with TOPWIN is its incompatibility with 64 bit Operating System & Windows 8 .

In this post we shall review an excellent Universal programmer MINIPRO 866 from AUTOELECTRIC Co. that works on all platforms including 32/64 bit Windows 8 .

 

                MINIPRO

Two models are available MINIPRO 866 CS & MINIPRO 866 A.

The 866 A has an additional advantage of ICSP – In Circuit Serial Programming – a real awesome support for ON board programming of SMD chips.

ICSP now supports ATMEL89S51,52, ATMEGA- AVR whole series and MICROCHIP PIC10F, 12F, 16F, 18F whole series,SYNCMOS SM59Dxx / SM59Rxx full range.

Minipro programmer delivers outstanding performance in supporting nearly 13k + devices that other similar products like Topwin are not capable.

IC SUPPORT LIST

http://www.autoelectric.cn/minipro/MiniProSupportList.txt

Download the IDE version 6.10 from :

http://www.autoelectric.cn/minipro/minipro_setup.rar

Always download the latest version as the list of support ICs is updated frequently.

Start the installation file by double clicking MiniProV610setup.exe application.

You can leave it to default location or browse to a preferred one.

  clip_image002

 

 clip_image004

 

Click on INSTALL to confirm USB Driver installation.

 

        clip_image006

Click “Install this driver software anyway “ to bypass Windows verification.

 clip_image008

Click FINISH to complete the installation.

clip_image010

 

Now connect the Hardware unit to the USB port .Under Device Manager you can see the device name as “MiniIProWdf” if the installation went through smoothly.

clip_image012

You’re all set to start the Programming.Open the IDE & if you get Reflash Firmware window , just click on Tools à Reflash Firmware from the IDE to install the latest updates

Obviously you should connect the hardware to the USB & your internet connection should be ON for this process.If there is no access to internet the Reflash Firmware window appears again.

clip_image014

 

clip_image016

Once the Reflash is successful , click on the “Cancel” button. (Yes it is not OK button ,it is Cancel button) !!

We shall see how to program PIC 16F877A IC .

Under Select IC à click Search and Select IC.

clip_image018

Under Type select MCU/MPU & start typing “PIC16F” inside the ‘ search device’ space bar.All the related PIC ICs will be displayed on the right pane.Select the target IC as , PIC16F877A.

Click on Select.

clip_image020

Ensure that 40 pin adapter is selected on top .Later we’ll see how to work with ICSP.

clip_image022

Click on “Information” button at the right top corner to learn how to place the chip on the ZIF socket.According to the diagram place the IC on the socket , pin 1 is always near the handle.

clip_image024

Lock the handle by pressing it down.

By clicking under DEVICE ,you can perform initial check for the IC .Blank check can be done & if you want to erase the chip , click ERASE

clip_image026

Following is the screenshot of Chip Erase function :

clip_image028

To load the HEX file on to the buffer click File à Open & browse to the location where you’ve stored the HEX file that is to be fused on to the target chip.

clip_image030

Select the HEX file & click Open.

clip_image032

The File Load Options should be in the File format “INTEL HEX” .The Binary option is to load a “bin” file.Here confirm INTEL HEX is selected.

clip_image034.

Under DEVICE click on PROGRAM to start fusing the HEX file.

clip_image036

On the next Chip Program window click “Program”.

clip_image038

 

clip_image040

You can see PROGRAM SUCCESSFUL if the fusing is finished.

To make a copy of a chip say, EPROM 27C256 following is the method :

Select Device as 27c256 using Search Device bar.

eprom1

 

Click on the Information button & place the Master IC on to the ZIF socket as per the diagram.

eprom2

Ensure that the VPP Voltage at the bottom of the screen is selected according to programming voltage of the chip (mostly it is 13.5 or 12v)

eprom6

 

Click the “R “ button to READ the chip to the buffer.

eprom3

 

Now remove the MASTER chip from the ZIF socket & place the SLAVE IC .This IC should be a fresh blank one or erased one under UV light.

Click on the “P” button on the top to start copying the data on the buffer to the chip.

eprom5

Same way you can make copy of PIC ,AVR or 8051 Microcontrollers.Remember that , if the source IC is previously LOCKED ,you can’t make a copy.

To program SMD ICs & other QUAD package ICs you can buy Converters on which this IC is mounted.

MINIPRO2

In the next post we shall review the ICSP model of MINIPRO 866.

Watch this demo video :

 

Universal Programmer MINIPRO 866CS for all PIC,AVR,8051,EPROM,….

 

For availabilty of this programmer contact :

cooltext753793315    cooltext753790696