Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] What is a State Machine in PIC and how can it be used for LCD?

Status
Not open for further replies.
A state machine is a programming construct, it is applicable to all microprocessors and microcontrollers. It CAN be used to drive an LCD but probably isn't the best method.
Basically, in a state machine, you define a group of conditions, each called a 'state' (might be a particular pin combination for example) and 'glue' them together with conditional jumps. Depending on the purpose of the program, you decide which state you are currently in, the one you want to change to then make the jump. You might like to think of it as a subroutine for each possible combination of pins and a controlling program that selects the appropriate one to call. They work efficiently in some cases but for driving an LCD it would be more efficient to toggle pins in a linear sequence than pre-defining lots of pin states beforehand.

Brian.
 

Then what will be suitable for LCD program? I was working to make an inverter. I've completed all the works, only the LCD is making the trouble. When timers is on, LCD goes mad. What can I do in this case?
 

What LCD and how do you have it interfaced?
What PIC?
Which language?
Which assembler/compiler?
What is the LCD supposed to show?

Brian.
 

Can anyone tell me what is state machine in PIC micros and how ca I use it for LCD program?

The state machines in the PIC are similar to finite state machines in digital circuits. Each state has a certain set of inputs and outputs (operations). There are a finite number of states performing all required operations. To know more about finite state machines, refer to this: https://en.wikipedia.org/wiki/Finite-state_machine

For the LCD, you should probably drive the LCD in a sequence, and consider this to be a single function/operation within any state/ state machine, instead of implementing state machines for just the LCD drive section.

Hope this helps.
Tahmid.
 

What LCD and how do you have it interfaced?
What PIC?
Which language?
Which assembler/compiler?
What is the LCD supposed to show?

Brian.

Here is the work linked back: https://www.edaboard.com/threads/310277/#post1328925 [see post no # 18]

MCU: PIC16F73B
Language: C
Compiler: MicroC v5.6.1
LCD need to show some indication, a voltmeter for Battery, and little bit extra for Name.
 

The LCD will only display what you tell it to. When you say "When timers is on, LCD goes mad" what is happening? The PIC timers should make no difference to the LCD signals. I suspect a bug in your software is causing another problem which manifests itself as a corrupted display but isn't related to the software actually writing to it. I think you will have to post a schematic and the source code for a more accurate analysis.

Brian.
 

Its all right, I've solve the problem. Just making some modification listed below:

1. Disabling interrupt when writing in LCD,
2. LCD is not being written every cycle, taking one cycle in 500 program cycle.
3. Keeping some 'asm nop' in between some critical timing points to remove noise.

Now its all ok and its solved.
Thanks.
 

Update LCD display only if the data to be displayed changes. You said it displays battery voltage. Use a backup variable to hold battery ADC value and check if previous ADC value is not equal to current ADC value. It true then only write to LCD.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top