Search |
 |
|
 |
| Author |
Message |
|
|
Posted: Jul 06, 2011 - 08:57 PM |
|


Joined: Nov 22, 2002
Posts: 12031
Location: Tangent, OR, USA
|
|
Crystal ball is VERY fuzzy but I wonder if the hakagirl's "real" quest is: "I just wanna get SOMETHING running. I don't know diddly about C, and not thrilled about spending all that time, so I just grab something off the internet to RUN!"
This is NOT intended to put (presumed) her down, in the least. We have had a spate of such queries in the last few months. Perhaps they represent the "new paradigm" of what it means to "program". We can try to guide. We can encourage. We can point to resources. We can nudge and suggest. OR, we can complain. We can throw up our hands and walk away (and I begrudge no body who does, because it is really, really, frustrating). We can tell everyone about all the effort we went through when WE learned "it".
So, lets try to be a bit understanding. Any of you who have techno-teens in your family or among close friends know what we are up against. They want to do without learning, but, if they stick with it, they will end up learning whether they intend to or not. At least part of what they learn (in the microcontroller programming realm, at least) will depend on their interactions with us.
In THIS particular case, I think we really need to ask: what is the OP's goal? What are YOU trying to do. And, how can we help you do do that? My very cloudy crystal ball suggests that you don't care what it is that you get running. but you want something, anything, that you can SEE do something.
For hakagirl, you need to know a few "facts". First is that every c program needs a function named "main()". It is normally written so that it contains an endless loop that NEVER exits. Second is that what you probably got, previously, were "libraries". These are chunks of code that are intended to be added on to an existing program to do something. They will not run, by themselves. YOU have to supply the core program that it gets added to.
Jim |
_________________ Jim Wagner
Oregon Research Electronics, Consulting Div.
Tangent, OR, USA
"The only thing standing between us and victory is defeat" P.G.Wodhouse in Wooster & Jeeves series
|
| |
|
|
|
|
|
Posted: Jul 06, 2011 - 09:51 PM |
|


Joined: Mar 27, 2002
Posts: 18520
Location: Lund, Sweden
|
|
|
Quote:
Crystal ball is VERY fuzzy but I wonder if the hakagirl's "real" quest is: "I just wanna get SOMETHING running. I don't know diddly about C, and not thrilled about spending all that time, so I just grab something off the internet to RUN!"
Then she has chosen something MUCH too complicated for a first project, Jim. |
|
|
| |
|
|
|
|
|
Posted: Jul 06, 2011 - 10:05 PM |
|


Joined: Nov 22, 2002
Posts: 12031
Location: Tangent, OR, USA
|
|
Oh, I agree, but has that also not been a recurring theme?
Jim |
_________________ Jim Wagner
Oregon Research Electronics, Consulting Div.
Tangent, OR, USA
"The only thing standing between us and victory is defeat" P.G.Wodhouse in Wooster & Jeeves series
|
| |
|
|
|
|
|
Posted: Jul 07, 2011 - 01:26 AM |
|


Joined: Jul 01, 2011
Posts: 14
|
|
okey.. first i've learned the basic of c languange and i don't know how to program avr using c...
and I'm working on the final project for college, about uvmeter.. so i just want to know how to read uv sensor and how to displays on lcd and pc
regards
MA |
|
|
| |
|
|
|
|
|
Posted: Jul 07, 2011 - 05:31 PM |
|


Joined: Nov 22, 2002
Posts: 12031
Location: Tangent, OR, USA
|
|
Great. You've made some progress in learning and in defining your problem.
Now, a couple of questions:
1) What is the nature of the output of the UV sensor? Is it analog or digiital?
a) If analog, what is the voltage range that you need to measure?
b) If digital, what is the interface? SPI? I2C (aka TWI)? Something else?
2) What kind of LCD do you need or want to use?
3) How do you want to communicate with the PC?
A note about program structure - typically there is a part at the beginning where you declare variables that need to be used globally (that is, anywhere in the program). Those to be accessed in an interrupt service routine also need to be declared as "volatile" in addition to their type (such as char or uint16_t).
Next, Usually, as a matter of convention, interrupt service routines (ISRs) are written out, in whole. If you need to use an ISR (common for UART, for example), be sure to look at the avrlibc documentation for the correct name for your micro. Also, note the ISR structure described, there.
Then you have a function
Code:
int main(void)
that contains the main perpetual loops of the program core. The usual first task in main() is initialization. You write to I/O ports and registers that will be used (ADC, UART, timers, and such) to give them their proper operation. After initialization, the program usually enters a big loop where status of the analog-digital converter is checked, where you trigger messages to the serial port, or write to an LCD.
Some may quibble with a few of the details that I've written, but it is, at the very least, a useful starting point. Because of the nature of what you will be doing, you may well be using libraries (especially for LCD). So, I strongly recommend reviewing the tutorial on "large" projects (anything more than a single .c file)
http://www.avrfreaks.net/index.php?name ... mp;t=48535
And the excellent tutorial on interrupts:
http://www.avrfreaks.net/index.php?name ... mp;t=89843
And the one on bit manipulation:
http://www.avrfreaks.net/index.php?name ... mp;t=37871
Be sure to scan the "Tutorials" forum. A lot of great help is there, for you.
Jim |
_________________ Jim Wagner
Oregon Research Electronics, Consulting Div.
Tangent, OR, USA
"The only thing standing between us and victory is defeat" P.G.Wodhouse in Wooster & Jeeves series
|
| |
|
|
|
|
|
Posted: Jul 08, 2011 - 10:50 AM |
|


Joined: Jul 01, 2011
Posts: 14
|
|
1. the output of uvsensor is analog with voltage range between 0-3V
2. i use lcd in butterfly stk502
3. to communicate i'm using ISP,
thanks for links.. ,
best regards
MA |
|
|
| |
|
|
|
|
|
Posted: Jul 08, 2011 - 05:25 PM |
|


Joined: Nov 22, 2002
Posts: 12031
Location: Tangent, OR, USA
|
|
Hello, MA -
Please note that ISP is used only to program a device. You cannot send data to your PC this way. Your previous post sounds as though you want to display data (from the AVR) on your PC, and ISP will not do that.
The standard methods are asynchronous serial with a UART (RS232) or USB. If you use USB with most AVRs, you will need to add a USB interface chip, such as FTDI FT232R. A few AVRs have USB built in. If you use RS232, you will need an RS232 interface chip, similar to MAX232 (there are several).
It sounds like you are using a Butterfly. IF so, you need no LCD libraries. There are tutorials about using the Butterfly LCD. Check http://www.SmileyMicros.com
You will need to use the analog-digital converter (ADC). 0-3V is an easy range to work with. There are tutorials, here, about use of the ADC.
Jim |
_________________ Jim Wagner
Oregon Research Electronics, Consulting Div.
Tangent, OR, USA
"The only thing standing between us and victory is defeat" P.G.Wodhouse in Wooster & Jeeves series
|
| |
|
|
|
|
|
Posted: Jul 09, 2011 - 02:40 AM |
|


Joined: Jul 01, 2011
Posts: 14
|
|
hi Jim,
first thanks for ur advice, i've made little program that i attach here.., so i've problem with LCD_UpdateRequired function, cause i use Dean's lcd_driver where there's on such function..,i use this function to tell LCD that's new data came,cause when i trying the code that's no change.. do you have solution for this problem?
thanks
MA |
|
|
| |
|
|
|
|
|
Posted: Jul 09, 2011 - 03:19 AM |
|

Joined: Dec 30, 2004
Posts: 8723
Location: Melbourne,Australia
|
|
| Sounds like another customer for the Arduino. |
|
|
| |
|
|
|
|
|
Posted: Jul 09, 2011 - 04:50 AM |
|


Joined: Nov 17, 2004
Posts: 6137
Location: Great Smokey Mountains.
|
|
Were you able to get anything working from Dean's Tutorial? Why are you concerned about the LCD_UpdateRequired function when as you say it isn't even in Dean's Tutorial. If you can get Dean's code working what do you need that function for?
Smiley |
_________________ FREE TUTORIAL: 'Quick Start Guide for Using the WinAVR C Compiler with ATMEL's AVR Butterfly' AVAILABLE AT: http://www.smileymicros.com
|
| |
|
|
|
|
|
Posted: Jul 09, 2011 - 05:34 PM |
|


Joined: Jul 01, 2011
Posts: 14
|
|
|
Quote:
Were you able to get anything working from Dean's Tutorial?
not all ,i need function to tell lcd that's new data came.. or u have link for lcd function?
regards
MA |
|
|
| |
|
|
|
|
|
Posted: Jul 09, 2011 - 07:53 PM |
|


Joined: Nov 17, 2004
Posts: 6137
Location: Great Smokey Mountains.
|
|
Dean's Tutorial tells you how to write to the LCD. Maybe I'm not understanding what you are asking.
Smiley |
_________________ FREE TUTORIAL: 'Quick Start Guide for Using the WinAVR C Compiler with ATMEL's AVR Butterfly' AVAILABLE AT: http://www.smileymicros.com
|
| |
|
|
|
|
|
|
|
|