Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

lcd using slave avr

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
hamedhamedi

Bascom Member



Joined: 12 Feb 2012
Posts: 70

PostPosted: Thu Jan 29, 2015 9:00 pm    Post subject: lcd using slave avr Reply with quote

Hi
In many industrial cotroll board,the lcd drive with a slave microcontroller.
I didnot find why it is,unless i get found that lcd is very slow.
Now i want to use a 2*16 lcd with a real time hardware use to drive mosfet.the delay in my code get a very dangerous condition.so i want to use a slavemicrocontroller to display 6 single variabe.
I dont know how to comunicate with slave microcontroller tosend 6 single variable!
One way is spi,another is i2c.but i dont know which one is easier to send 6 single variable.
And also i dont know who to identify the ariable from each other inslave!
Any idea and sample code will help me.
Regards

(BASCOM-AVR version : 2.0.7.8 )


Last edited by hamedhamedi on Wed Feb 04, 2015 9:37 am; edited 1 time in total
Back to top
View user's profile
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Fri Jan 30, 2015 12:02 am    Post subject: i2c LCD... Reply with quote

In the Bascom-Arduino part of this forum. There you can find a piggy-back board for i2c.

With an adapted library.

And perhaps a search for the other questions.

Have fun
Ben Zijlstra
Back to top
View user's profile Visit poster's website
hamedhamedi

Bascom Member



Joined: 12 Feb 2012
Posts: 70

PostPosted: Fri Jan 30, 2015 7:47 am    Post subject: Reply with quote

Thanks.
Can it improves the time of writing to lcd or it just reduce pinout?
Regards
Back to top
View user's profile
snipsnip

Bascom Member



Joined: 10 Feb 2014
Posts: 66
Location: Melbourne

australia.gif
PostPosted: Sun Feb 01, 2015 10:24 pm    Post subject: Reply with quote

Is the slave processor on board or remote?
If remote - how far?
Hardware uart?
How many spare io pins on each processor?
6 x separate variables (byte,word,long etc?) or 6 x single length separate variables?


How slow is the LCD? are you using CLS / better to just overwrite.
How much time do you have to send the data?

Just some thoughts
cheers
Simon
Back to top
View user's profile
hamedhamedi

Bascom Member



Joined: 12 Feb 2012
Posts: 70

PostPosted: Wed Feb 04, 2015 9:33 am    Post subject: Reply with quote

Hi snipsnip
thank you

[/quote]Is the slave processor on board or remote? If remote - how far?
Quote:

the slave proccesor is on remote and the lenght of track between master board and remote noard is about 10 cm.the master board and remote bord connected via pin header.

Hardware uart?
Quote:

no usart used.
i want to use i2c or spi,because it is implemented with address and easy to use

How many spare io pins on each processor?
Quote:

the 8 pin is free on master board and slave

6 x separate variables (byte,word,long etc?) or 6 x single length separate variables?
Quote:

6 different variable, single,word,byte variable,that i use max 2 digit after point for single, like 12.34

are you using CLS / better to just overwrite.
Quote:

no,i use over write.

How slow is the LCD? How much time do you have to send the data?
Quote:

about 20ms,i measure in osciloscope,with set a bit before writing to lcd and reset it after write to lcd.

Thanks
Back to top
View user's profile
JC

Bascom Member



Joined: 15 Dec 2007
Posts: 482
Location: Cleveland, OH

usa.gif
PostPosted: Thu Feb 05, 2015 6:49 pm    Post subject: Reply with quote

I think you should think about the overall structure of your program, and if it is possible to "speed it up".

Using a serial connected slave LCD is certainly possible, but you would have to use a hardware I2C or SPI or USART module in order to see any real speed gains.
If you used a software I2C, SPI, or USART, it would be slower than just outputting data to the LCD itself, connected directly to the micro.

If the critical timing part of the program is interrupt driven, then writing to an LCD in the Main Loop should not impact the critical processing.

If the LCD routine is too long as it is outputting a 16 character string for each line, then one could certainly break this up and output one character at a time.
There are several ways to do this, but there is some overhead no matter which approach is taken.
A typical approach is an interrupt driven buffer.

Several additional thoughts:
If you do elect to use a slave uC, don't discount the USART.
Bascom already has the ability to do interrupt driven, ring buffered USART communications, making this easy.
You would still need to be very careful in how the program was structured, however, so that this did not slow down the time critical code.

Also, note that the Xmegas run at 32 MHz, giving you twice the processing power of a 16 MHz AVR.
The Xmegas also have priority interrupts.
The time critical code could use the high priority interrupt, the LCD display routines, could use the low priority interrupt, to either send data over a serial communications link, or just to feed the LCD one character at a time, (via a once every 1 mSec interrupt, or similar).

Remember that LCDs are "slow" in terms of the micro running in the MHz clock range, and the human eye is very slow.
One can have a "slow" LCD driver routine that is still so fast that the human can't tell the difference.

JC
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum