View previous topic :: View next topic |
Author |
Message |
e-learner
Joined: 20 May 2014 Posts: 21
|
how to write OR display data read by adc in LCD and edit? |
Posted: Mon May 26, 2014 1:36 am |
|
|
http://s1.postimg.org/k52ed0iq7/concept.jpg
Hi friends,
anyone by seeing the above diagram suggest the idea of the code to write, having four DI's one for mode (capture mode and edit mode for LCD) for reading the ADC value and set the min and max value....increment & decrement button to be used for selecting the mode (as arrow keys), and save button is used to save the selected mode or enter into a particular mode. Finally the total circuit should act as ADC comparator and digital indicator with controller.
Hope you guys will get what I am expecting? _________________ e-learner |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Mon May 26, 2014 6:00 am |
|
|
I'd start by getting the PIC to blink an LED at 1Hz to confirm the hardware is good.
Then use the flex_lcd driver that PCM_P wrote(in the code library) to confirm the LCD module is good.Hint, your schematic is in error.
Once that works right, then get the 'buttons' to function. Cut code to see a button was pressed by displaying it's name(or number) on the LCD.You will require some debounce though, a topic covered here several times.
part four would be to read the adc, display the raw value on the LCD.
part five.combine all that you've learned into one big program.
CCS supplies LOTS of great examples of code you can learn from in the 'examples' folder.
Once you've got past step two report back...
The 'secret' is to breakdown the assignment into smaller sections and complete each one BEFORE trying to do something else.
Overall , less than a week of easy 2-3 hours per night and you're done.
hth
jay |
|
|
e-learner
Joined: 20 May 2014 Posts: 21
|
RE: |
Posted: Mon May 26, 2014 7:09 am |
|
|
Thanks for your reply, but still I am not clear how to use the buttons to work the lcd in edit mode, like moving the cursor and enter the data in LCD directly and saving the entered data using the buttons? Is there any example in which LCD is used in edit mode.
And pls mention me the error in schematic....... _________________ e-learner |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
|
Posted: Mon May 26, 2014 7:17 am |
|
|
So this is in Proteus, not real hardware...and likely a school project.
One data connection to D7 on the LCD is missing.
You are missing VEE circuitry completely.
If you want code to make changes on the LCD using a push button interface
you'll need to either build the message in PIC memory and edit it then
send it to the display or read the display memory. _________________ Google and Forum Search are some of your best tools!!!! |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Mon May 26, 2014 7:52 am |
|
|
Some but not ALL errors
1) no ground to PIC
2) no power to PIC
3) no clock source(xtal with caps or ??)
4) LCD Vee not connected
5) LCD D7 not connected
6) no pulldown R on INC
7) no pulldown R on DEC
8) no pulldown R on MODE
9) no pulldown on SAVE
and that's just the easy ones to spot...
You MUST tell us if this is REAL hardware of 'Proteus/ISIS' simulation.
if the former we can help you get it working
if the latter you will NEVER get it to work properly,can't be done!
hth
jay |
|
|
e-learner
Joined: 20 May 2014 Posts: 21
|
RE: |
Posted: Mon May 26, 2014 11:33 pm |
|
|
OK thanks for all your reply... _________________ e-learner |
|
|
RF_Developer
Joined: 07 Feb 2011 Posts: 839
|
Re: how to write OR display data read by adc in LCD and edit |
Posted: Tue May 27, 2014 3:28 am |
|
|
e-learner wrote: | ...suggest the idea of the code to write, having four DI's one for mode (capture mode and edit mode for LCD) for reading the ADC value and set the min and max value....increment & decrement button to be used for selecting the mode (as arrow keys), and save button is used to save the selected mode or enter into a particular mode. Finally the total circuit should act as ADC comparator and digital indicator with controller. |
This is all basic firmware development stuff, but here goes:
Whenever you get a problem like this, you need to split the code up into logical chunks; related but separate functions that you can work on easily.
At first sight this problem has four basic functions, in no particular order:
Reading the switches.
Converting the input to digital with the ADC.
Doing some stuff to the data.
Displaying the result.
It makes sense to do these four, and maybe some stuff to link them to each other, in a simple loop that does each in sequence. Each can be developed and tested on their own, so you can build the code up step by step.
The first thing to do is none of these however. The first is to get the PIC running at the right speed. That's done with a very simple LED flashing code. Forget the LCD, for get the ADC, forget the switches, in fact forget everything else until you've got the PIC up and running at the speed you expect.
Then pick one section and work on that. You may want to leave the worst till last, or you may want to dive right in and get the tough stuff out of the way. Its usually the LCD that causes inexperienced coders the most trouble, so that's where to start/finish after you've got the PIC running with the LED flasher. Be very aware that real LCDs tend not to be very much like their Proteus versions. Just because you've got it to work in Proteus has little bearing on whether it'll work with real hardware. The problem is Proteus, which doesn't simulate PICs and LCD modules very well.
Then get each section working, one at a time. Finally, when you know the bits are working separately, tie them altogether with code. Its at this stage that timing and sequencing problems often show themselves. Do you really need to sample the ADC that fast when the LCD can only cope with 4 updates a second? What about switch debouncing (which really you should have sorted by this stage). These are just two of the possible problems that can arise in even such a simple project as this.
The key is to do any project stage by stage. Splitting it into manageable chunks makes development much simpler.
Later you will find that you can use and adapt these firmware chunks in other projects. |
|
|
|