The n00b question that must be asked on joining the forum

Go To Last Post
53 posts / 0 new

Pages

Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Good day Freaks,
Its all catching up with me, and I just must learn C and micros!

Having done some electronics training four or more ears ago most is gone, there was a bit of PLC stuff (I thought ladder logic was clunky and stupid, but boy was it easy to do process control!!), and six months assembly on the HC11, but transistor biasing -- all gone.
What I am going to do (try implies failure) is build a charge and load controller for our fantastic wind turbines. I would like to have 3-phase active rectification on the front end, and PWM to multiple outputs. In/out will need voltage and curent detection. I see this as being a pretty simple board with 10 or so fets and no transistors. I spent a week looking for w-phase zero crossing circuits to copy, or an active rectifyer controller IC but no luck...

SO

I must start at the very beginning and do what Ive wanted to do for many years now, and get my own Micro development gear.

Thus the noob question:
Given my short term goal, is this a feasible first or second project given that I know no C, am not afraid to get dirty, and a fairly tight budget (hence its been four years to actually doing it)
I was recommended to get a butteryfly to start with and move on from there.
It looks like ICD is really very useful, but do I 'need' it at this stage? and is it posible in a linux envionment?
Ime sure these are illegal questions, but what programmer is the best option. It seems I can get dragons and stk500's locally. but they are more than I will be allowed to spend I think (busy family of three hungry girls competing for funds with daddy).

Then theres C.
There are a few books in the Uni Library that looked alright.
Embedded C programming and the Atmel AVR
AVR : an introductory course
Programming and customizing the AVR microcontroller
AVR RISC microcontroller handbook
Is there one amongs these that would suit the complete c and atmel n00b. Smileys book looks like the way to go, but I have the others available.

The greatest challenge is persistant time and support. I feel that if I go ahead with this that I will need your support. In what way can I rely on you all for help. I dont want to be a total leecher, just an almost total leecher ;)

Anyway, ime unformed. Mould me into an ass kicking micro engineer!

tia

Jasper

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Regarding C - until I joined my current company I'd never programmed in C (I had used many similar level languages), so I have effectively learnt C from scratch using the resources on this site. At the top of this forum there is a Sticky post entitled "Find/Post your Online C Books & Tools here ....", there's a number of books and tutorials on the subject of C. I'd recomend reading:
The C book
http://publications.gbdirect.co.uk/c_book/
It's more of a general C book (then AVR/uC/Embedded specific) but it gives you good overall coverage of the language.

I'd also recomend downloading AVR Studio and WinAVR and just experimenting with the Simulator within AVR Studio (worked for me). How long it takes for you to pick up C depends on a number of factors e.g. have you used other similar langauges, what do you actually want/need to do in C.
For AVR specific programming I'd suggest doing a little bit in assembler, nothing complex though. It'll give you a little understanding of what's going on under the hood.

Ben
-Using IAR (& ocasionally CodeVision)
0.7734
1101111011000000110111101101

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank Ben,
Ime battling installing AvrStudio at the moment. Tried wine, wine from git, crossover. Still not working. I got the closest with normal wine, but then got that avrframework error. but this is another story.

Do I want/need to do it in C? this is part of the question. i was told by a friend of a friend that he does everything for pics in basic, and that C is overkill. For the kind of realtime control I want to do is C nescesarry. I would like to know it tho.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sometimes alchol and computers don't always mix.

Ben
-Using IAR (& ocasionally CodeVision)
0.7734
1101111011000000110111101101

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do you need to do it in C?

Answer: No.

However in my opinion I prefere C
E.g.
In C I would write:

while (!(PLLCSR & (1 << PLOCK)));       /* Wait for PLL Lock to be set. */

where as the assembler version would be

IN      R30,0x29
ANDI    R30,0x01
BREQ    PC-0x02

Both pieces of code do exactly the same thing. However for me the C version is easier to read, write & understand.

You can write AVR programms in Basic however this is less well supported. C is by far the more common language. The debate on C vs Basic could rumble on forever. But In My Humble Opinion I use C, most other people use C, I can do what I want in C, therefore C is what I use.

However other people will prefere other languages. It's all a matter of individual taste.

Edit: Re-clarifying my post

Ben
-Using IAR (& ocasionally CodeVision)
0.7734
1101111011000000110111101101

Last Edited: Tue. Aug 28, 2007 - 10:59 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you are developing on Linux you probably want to take a squint at the GCC forum as the various options for programmer software and other dev tools are discussed regularly there.

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

BenG wrote:
Both pieces of code do exactly the same thing. However the C version is easier to read, write & understand.

But you weren't comparing apples with apples. I imagine the Asm programmer would have written something like:

check_PLL_lock:
 IN    temp_reg, PLLSCR
 ANDI  temp_reg, (1 << PLOCK)
 BREQ  check_PLL_lock

Which, to an Asm programmer, is going to be as readable as the C code is to a C programmer.

(in fact your "BREQ .-2" error is an example why the Asm programmer would not have used hard coded offsets but branches to labelled statements)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Clawson,

You are quite correct, I simply grabbed the line and asm equivilant from a project I currently have open.

In reality there is no answer to "Which language is best" just "Which langauge do I think is best".

Ben
-Using IAR (& ocasionally CodeVision)
0.7734
1101111011000000110111101101

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ben,

Yup I was just playing Devil's Advocate to quell yet another C vs Asm war, my own preference is well known on here ;)

BTW Did it really generate "BREQ .-2"? Surely that's a jump back to the start of the BREQ so it could never get out of that loop?

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry, I wasnt asking which language is best; But it does leave me feeling a little worried. Is it only AFTER ive read the whole online book that I will be able to thin about how little I know, and attempt to make a micro jump and squeak. I was hoping that there ways in which I can learn by doing, and patting myself on the back for getting something right.

As to the hardware, Any ideas? Will the butterfly see me through the learnign curve?

cheers

Jasper

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The butterfly and book from www.smileymicros.com is a GREAT way to get started with AVRs

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
What I am going to do (try implies failure) is build a charge and load controller for our fantastic wind turbines. I would like to have 3-phase active rectification on the front end, and PWM to multiple outputs. In/out will need voltage and curent detection. I see this as being a pretty simple board with 10 or so fets and no transistors. I spent a week looking for w-phase zero crossing circuits to copy, or an active rectifyer controller IC but no luck...

Why not just use a standard 3-phase bridge rectifier on each wind turbine, paraleling their outputs and follow that with a PFC converter to produce a nominal DC bus.

If energy storage is required, select a bus voltage to suit charging of batteries.

The bus voltage can then be converted to any required output voltage. The ADC of any suitable AVR can be used to monitor and control the system etc.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Although I really appreciate Cliff's recommendation, I do not think that either the Butterfly or especially my book would be good for the OP. He has a very narrowly stated need and budget, and learning C will require a large commitment of time and resources. If the OP had said, 'I want to learn a good programming language and apply it to projects such as doing a PWM for a wind generator", then I might agree that learning C with my book and the Butterfly would be a good idea, but based on the OPs post so far, I say just use the free materials on the web.

Smiley

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@rberger: I dont understand why you use a PFP? I thought about having a smps either buck or boost, but i) I have no experience with these , ii) The input voltage range is quite large.
I thought that an active rectifier would keep the component count down and allow me to shut the turbine down all with the same componentry. Also to keep the turbine load control on the input side, allowing for a more modular desig; that is to keep the turbine running by extractign less power, is better than to stall it and not have it start again. The same load control could be done on the charging side, but I think it is better the other way

@smileymicros When I say budget here I mean to be realistic. I hav read many posts on your forum regarding the failings of home cooked programmers. So I am aproaching this with caution.
I am willing to spend more on a proper programmer that will work now and forever than get the wrong thing constantly.
I cant get a Dragon and an STK500 and a whole bunch of books.
But I could get One of those things. I thought your idea of starting with a butterfly, and then when when I'me familiar with this go for a dragon or an STK500. Is this flawed?
-But- I still need the knowhow.
Your book costs as much as a dragon here.
-But-
'I want to learn a good programming language and apply it to projects such as doing a PWM for a wind generator' (What were you assuming I meant in the above? That I dont want to spend any money and just want to have a curory go at it, and when C is too hard throw it all away? no, I want to learn a good programming language and apply it to projects such as doing a PWM for a wind generator ;) )
So your book may well be worth more than a dragon if it helps me turn chips and wires on my desk to projects realised, rather than dreamed.
Thank you for your honesty regarding your book. If it really isnt suitable, can you suggest a micro focused C resource on the web.
SHould I abandon the idea of a butteryfly and get straight into an STK500 or Dragon (with the money I saved by not getting the book...)

This is something I want to see though to completion -but- I would like to be able to do useful things at least by christmas.

(I am an OP? What is an OP? (Who am I...?))

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OP = Original Post, used to refer to the person who started the thread.

There are free resources shown in the sticky: https://www.avrfreaks.net/index.p...
These resources combined with questions on AVRFreaks should be all you need.

Lots of folks start with a Butterfly, most love it, some hate it. It has a bootloader so you don't need a programmer for it.

If you want a programmer, I'd recommend the Dragon just to get started.

Select a platform, such as a Butterfly if you want to use a device with a bootloader, or something you can program with the Dragon (like boards from Olimex or ones you can find in the AVRFreaks tools section) and as you progress, you will be able to refine your needs.

Smiley

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks Smiley,
I have been through and through the list of resources looking for something micro specific (pref AVR), certainly I'me ignorant.
Is the idea to learn C, then start on the Mico.

As I will be developing in a linux environment should I post a question on tutorials etc. over in the gcc-avr forum.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Smiley and I will likely disagree on this... My personal belief is learn C on a PC... And then learn the more restrictive microcontroller environment. The reason being is that on a PC under an OS, you have the protection of the OS, and virtually no limitations. Sure you can't access hardware directly, but at this stage you're learning a language, not hardware. Also by working on a PC, which has the concept of a console, you can put all kinds of debug info to the screen which will help you learn to see how things work... you cannot easily do this on a micro.

Linux is perfect, as you have the text console, and any development will default to using it. So you're all set to go. Another nice thing is GCC... any compiler specifics of GCC, and it's realted tools, that you might learn, will carry forward with GCC for the AVR. (obviously nothing architecture-specific will carry forward)

Once you understand the language, move on to the more restrictive microcontroller environment. At that point you'll need to learn the hardware specific items, and learn to work without many of the nice library features you had on the PC.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

Last Edited: Tue. Aug 28, 2007 - 11:03 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Tutorials is for tutorials and questions about specific tutorials in the specific tutorial thread. Don't start a thread there unless it is to post a tutorial.

If you have questions specific to GCC then the gcc-avr forum is good.

Post other questions on the general forum and if you get it wrong, someone will point it out.

Smiley

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@glitch This seems like a very mature approach, but wont it take me years to get to the level of understanding C (on any platform)

@smileymicros
Who is the intended audience of your book?

Aarrg Ime going mad with ignorance.

Thank you all.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't think so... you can usually get the basics down pretty quick. You can actually do both in parallel. Once you get the basics down, start learning the micro, as you get to more advanced things (non-hardware) you can test them out on the PC again to see how it works.

How quick you learn is really up to the type of person you are, and how easily you pick things up and understand them. You can learn C in days, or months... depends on you.

The nice thing about C is that the language is the same no matter what architecture you're using. Leaving you to only deal with any architecture/device specific issues when you move from one to the other.

let's take the classic "hello world" example. The program will look exactly the same on virtually any architecture you compile it for.

#include 

int main(void)
{
  printf("Hello World!\n");
  return 0;
}

I say virtually any, because architectures like the AVR don't have an OS, or the concept of a console, so by default the program would not know where to send the hello message to. Nor does it have anywhere to return to. So you will need to account for these platform-specific issues on the micro.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

Last Edited: Tue. Aug 28, 2007 - 11:35 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

cheers glitch.
I will start with the C book recommended.
I am still hunting for the tutorial "Holding your hand through your first experience with C and Atmel AVR"
(yea I'me still scared)

So the message about hardware is get a dragon. its only $20 more than a butterfly. But does it work in a Linux environment. I love the idea of watching my micro work as I step through the code bit by bit...
I assume that the dragon is a programmer and I still need a micro and some led's not get it to do anything. Can a dragon do in-circuit debugging and all that jazz on the Butterfly?

Being as honest with myself as possible... I think that somehow I imagined that I could learn a nice small amount of C that would make the task seem less enormous. That somehow I would need to know less C to programme a Micro, and that this would be safe and friendly.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is this a new thread...
The ATmega169 in the butterfly looks like a nice chip with heaps of ADC's and a few (but maybee not enough) PWM outputs.
How much of this goodness can be accessed though port D and B? Is there any way of getting access to more i/o than this?

It does look like for a novice that its not a good long term solution, due to not being portable to a smaller standalone circuit. But an LCD is nice...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Scarletpimpernal wrote:

@smileymicros
Who is the intended audience of your book?

A highly self-directed learner who is willing to dig into a variety resources and understands that no single source can meet all of any one person's needs.

Smiley

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello

Just my five cents.
I started with the AVR about a year ago. I knew nothing about the AVR and only very, very little of C.
I started out with buying an STK500 and then a set of Smileymicro's book and a butterfly.

Basically what I did was, I read the data sheet for the ATMega88 (my AVR of choice), wired it up as the new controller in an existing project, so it would work according to the data sheet.
Then I designed, ordered and assembled the PCB.
Final step was to start programming, using the excellent AVRStudio and even more excellent WinAVR programs, with Smileymicro's and a few other books, as well as the world's best forum (you guess which :) ) as references and the STK500 as in circuit programmer.
It worked excellently.
I never used the Butterfly. Still have it somewhere, but I suspect I won't use it ever.. Unless I have to experiment with some of the finer points of the AVR such as bootloader, ect..

Cost to get a basic familiarity with the AVR and C:
STK500: ~70 USD
PCBs: 250 USD
Components: ~20 USD
Smileymicrokit: 125 USD
.. And 'round 14 days of assembly, programming, etc..

I still occasionally use the 89C4051, but mostly because I have some in my component cupboard. Once that supply is up.. Well, then I'm done with those. AT89s are SO 80s :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Pimpernel,

While the Dragon is possibly the best product in the entire Atmel range that alone is not much use for learning to program microcontrollers. What you need when starting out is an easy input mechanism you can read (like buttons on the STK500 or the joystick on the Butterfly) and an easy output mechanism (LEDs on 500, LCD on Butterfly). So personally I'd suggest you get the $20 Butterfly first (there's even an argument for getting two - use one "normally" and load the other one with Buttload to use it as an ISP programmer for later designs and to rescue the first one if anything ever happens to its bootloader code). Maybe get the Dragon second when funds allow.

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
@rberger: I dont understand why you use a PFP? I thought about having a smps either buck or boost, but i) I have no experience with these , ii) The input voltage range is quite large.

The use of a PFC (Power Factor Corrected) boost regulator is precisely for the reason of wide input voltage range and why I suggested this method. Try and find out about simple PFC IC's such as the MC34262, etc.

The PFC boost regulator will track the input voltage and boost it to the required output. The PFC part of the boost converter will work over most of the input sinewave, not just that part where the sinwave input exceeds the bus voltage by the rectifier voltage drop.

i.e. allmost all of the input power is used, not just the peaks.

Ron.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Wasn't Dartanian the Scarlet Pimpernel? I recommend buying a ready to use 'development board' that will be used as your prototype wind controller, and I also recommend using a commercial compiler... less learning to deal with at the beginning. Switch to the compiler the unix pros use after you reach the limitations of the commercial compiler. Bd I like: ere.co.th mega32 board (about $32) and companion cables and io screw terminal boards and companion programer (about $5) and the imagecraft compiler (about $200). I have lots of programs for this combo you can use for examples.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Wasn't Dartanian the Scarlet Pimpernel?

No, d'Artagnan was "the fourth musketeer" in the novel "The Three Musketeers" by Alexandre Dumas (http://en.wikipedia.org/wiki/The...).

The Scarlet Pimpernel is the lead character in a novel with the same name by Emmuska Orczy (http://en.wikipedia.org/wiki/The...).

The story of The Three Musketeers takes place some 150 years earlier (around 1625) than the story of The Scarlet Pimpernel (1789).

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I knew someone here had more trivia in their brain than me. Good troll huh Johan?

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Or "Alexander Dumb-ass", to quote from The Shawshank Redemption...

Four legs good, two legs bad, three legs stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'll sadly drag this back on topic, I think, to put forth what I think.

Before starting with AVR for a project this past spring, I had been doing a bit of programming, though no C. Mostly it was PHP, so I guess the difference in syntax wasn't too big, but the language itself was new. I basicly did what you want to do, learning by trying, and it worked quite nice. Of course there were numerous errors along the way, but I eventually got to the goal.
I used a Dragon and "loose" Mega168s to learn, along with LEDs. Also, I used AVR Studio.
To begin with, I got used to the device by just having it do some flashing with the LEDs, trying out how function calls worked, getting to know header files and eventually using one of the built-in timers to get a feel for interrupts.
I had a beginner's book on C++ (not optimal, but it worked) to guide me in the more complex syntax, and just used trial and error to get the chip to do what I wanted.
Yes, it is much easier to use a Butterfly or debugWire if you want to debug your application, but I used the LEDs instead. They work well to indicate where in your program you are, however, getting data out that way isn't easy.
I only recently found (or rather looked at) the debugWire feature - but it's really neat (wish I had thought to look at it sooner).

All right, so I've been rambling. I tend to do that... I'll just continue for a bit.

I guess my point is that you can learn "on the fly" (I did), but if you haven't done any programming in C or similar languages, it might be difficult to start off with a microcontroller. You don't have to get a development kit (like the 500), but it has everything included, so sometimes it's easier. It might be harder too, since it's another thing to learn and understand. With "my" approach, all I had was what I needed and wanted.

Ugh, I feel like I've left more things unclear than when I started. Hope it helped a bit at least.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you all.
I have started on what feels like the enormous task of earning C using "The C Book" and "Programming Microcontrollers in C" simultaneousley which is working thus far, as one is almost too in-depth, and the other almost not enough...

@TrainzStoffe I really appreciate you saying this. As much as I can see the merit in Glitches idea it left me feeling like I would spend years learning C before I could even touch the micros... poor things they need fiddling with straight away. What is debugWire (it sounds like using a single pin as a debug output...) what hardware do you need to use debugWire (can this hardware be used in Linux?) Also what is the "loose" Mega168s?

@bobgardner What are the limitations of the gnu compiler? I am using a Linux platform so it just seemed to make sense to use what is here.

@rberger Thanks again for this, I look much more into it. (without having done it...) Can you get buck and boost buck topologies for PFP?

"They seek him here they seek him there those Frenchies seek him everywhere" But luckily he spelt it wrong way back in the day so they wont find him with a keyword search ;)~

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you are using Linux then you don't really get a choice about the compiler anyway. I don't believe that any of the others (except Rowley perhaps - http://www.rowley.co.uk/avr/ ) are available as Linux executables. So I'm afraid you'll have to put up with the most widely used compiler on planet earth and all it's "limitations" I'm afraid - hard life but it's Hobson's choice.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Scarletpimpernal: I knew I would have to clarify myself... :)

debugWire (dW) is, indeed, a single-pin connection (uses the Reset pin) which allows debugging in-circuit. (You might need an ISP connection to enable dW, but you'll most likely need this to program the microcontroller anyway). As to if and how it works under linux - I really don't know. AVR Studio (which I use) seems to be limited to windows machines.
I'm using a Dragon to use debugWire. I don't know if the other solutions are capable of this, but the product specifications should be clear on this.

And with "loose" 168s, I meant placing them directly on breadboards (http://en.wikipedia.org/wiki/Breadboard), not on a development kit or such.

On learning C: Do try and experiment, but I would suggest reading through the first chapters of the book first and thinking when and how you want to do what you just read. Then, read it again and try to write a simple program using it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Alternative: sign up for "Bob Gardner's Course in C Distance Learning by Graduated Examples" given via email. Prerequsites outlined several messages ago.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you Bob, the dv. boards look really good, but theres no way I could afford the Imagecraft compiler.
With the intention of starting a flame war to make me feel that this thread is more important... What are the limitations of gcc? and I guess what makes imagecraft that much better.

I'me just kicking myself I didnt start on C alot earlier! Hey I'me only at chapter 2 but already I can do little things. I wonder if there is any calculus libs... Still I'me starting to understand what my friend said when he said it takes 10 years to really understand C...

Breadboard is fun, and those little in the pictures of the single board 8088 makes it look even funner.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think the ability lo learn something new is partly genetic. I have never been able to force myself to slog thru a tutorial for a program... and I've started a bunch of em. Maybe I have Attention Deficit Disorder. I've seen people just pick up new stuff and run with it... amazing.
I've been fiddling with computers since hi school. Several times since the '70s, I've decided 'Well, this unix stuff is really taking over everything. I guess I better figure it out' and I'd get a book or sneak into the seat at the SG or something. I could issue 2 letter commands like ls and ps ok, but try to find which directory a file is in.... I think its the find command... lets try a man page..... whoops! scrolled off the screen. Need to do a pipe to more.... ok, find regexp... lets try and understand a regular expression.... hmmm.. * and ?... sort of like dos.... wow lot of stuff in there... ok... lets edit up a c file... learn vi.... ok ready to compile.... make seems understandable, but nobody just puts a command and a file on one line... they need to create macros with rules so the whole process can be invoked with one line... typical unixy terseness. The free software guys really loved unix, and they thought it worked so great that they copied every quirk and behavior of the original 1970 bell labs version, and now 40 years later, we have all that legacy 2 letter commands from the days of teletypes in our fine gcc compiler. Go ahead, skip to the chapter on make files... first get a pot of coffee. That is the chapter that usually sends me off all frustrated and confused.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I was lucky, I had a good bunch of friends to hold my hand while I lost my mind, and found it again in terminal, ah the blinking cursor is home now... (now ve been reprogrammed and rewired)
Which of the ere boards did you get? there are quite a few mega based boards and they all look interesting for different reasons.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The mega32 board has all the io ports on 2x8 IDC headers, and they sell IDC ribbon cable to screw terminal boards. This makes attaching something quick and easy.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Scarletpimpernal wrote:
With the intention of starting a flame war to make me feel that this thread is more important... What are the limitations of gcc? and I guess what makes imagecraft that much better.

No need for a flame war but you are the second person in as many days to assume that GCC has some kind of limitation. It doesn't, it's undoubtedly the most widely used C compiler on planet earth and in many professional environments - not just for "hobbyists". For example I used arm-gcc for the development of a video telephone that sold about a quarter of a million units.

It's true that because it's a generic (and principally Von Neumann architecture) based compiler that the AVR specific port may not be quite as efficient as some of the specifially AVR targetted compilers but we're talking maybe 5% larger code than the best of the other compilers in the worst case.

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

It doesn't, it's undoubtedly the most widely used C compiler on planet earth ...

Hmmm.
Quote:

I used arm-gcc for the development of a video telephone that sold about a quarter of a million units.

So, for the "most widely used" does that count as "1" or "250000"?

Hmmm. I'd like to see some basis for the "undoubtedly" and "most"--awful lot of superlatives there. "Widely used": certainly; all types of apps: certainly; many targets: certainly. Undoubtedly/most: Hmmm.

Yes, there is a GCC core in the WinAVR and other AVR-targeted packages. Is the AVR code generator that is included in the GCC port for AVR targets the best that it can be? Even if the xyz target >>is<< the best, that doesn't necessarily make the AVR target so. That is like saying that Ford (or Toyota or Honda or GM or whatever) undoubtedly sells the most vehicles in the world, therefore their Abc model pickup truck >>must<< be the best choice for your application.

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I assumed the oposite, and was interested as to what limitations there are in gcc. after all , all the good operating systems are compiled using gcc (and the whole kit and kaboodle) 8)

This is the kind of thing I an only ask once, as only total ignorance allows it: Of all the fundamental things 'The C Book' dosnt say is, ewhen oh when to use a ;, and when oh when not to? I thought it would be obvious: to put them at the end of statements. but dosnt seem so.

cheers

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Scarletpimpernal wrote:
This is the kind of thing I an only ask once, as only total ignorance allows it: Of all the fundamental things 'The C Book' dosnt say is, ewhen oh when to use a ;, and when oh when not to? I thought it would be obvious: to put them at the end of statements. but dosnt seem so.

Knowing better, I take the bait.

What 'C Book' does not tell you that a semicolon is used to terminate a statement?

I seriously, as in really really want to see this 'C Book' you mention.

Smiley

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It must be in there somewhere, but I cant find it.
I think I have it sussed, its just strange not to be mentioned...

http://publications.gbdirect.co.uk/c_book

There are some strange things in there, like an 'answer' to an example that requires

 10*C - '0'

to work, without the

- '0'

the results are giberish, but why... I know we do that in mathematics all the time, -0 and *1, but usually in cunning ways that make sense.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There is a great difference between

 10*C - '0'

and

 10*C - 0

In the first example the character literal value '0' is used. All characters have a numerically encoded value. In many cases the encoding used is ASCII or some extended/expanded variation of it. In all of those the digits are encoded the same way. The character '0' has the numerically encoded value 48, and then the rest of the digits follow ('1' is encoded as 49, '2' as 50 and so on.

Now, suppose you have a character variable containing a digit character and you want it's numerical value, how would you do that? You's subtract 48 from it, yes? Instead of typing out the explicit value in the source code, many C programmers prefer to say "the numerical value of the character zero", which we by now know is written '0'. This also takes height for he situation that numerical digits are encoded with another base number (the "C" standard guarantees that the digits then come in order). So if some odd machine/OS/compiler decided that the digits are encoded starting at say 42, then subtracting 48 would not work, but subtracting '0' would.

Subtracting the numerical value zero as in the second code snippet above is exactly what you think it is.

So now, does the getnum() function in exercise 1.5 makes more sense? I suppose that you actually was talking about that, and the code snippet

value = 10*value + c - '0';

Also: I actually sifted through the first sections of that online 'book' you linked to, and I can't find anything mentioning the usage of the semicolon (;) in "C".

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

theusch wrote:
So, for the "most widely used" does that count as "1" or "250000"?

Nope in this case it'd be about 30 - that is the 30 programmers on my team who used it during the development.

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Huh... I also can't find where he notes that ; terminates a statement, though I'm not going to search the whole book. Odd.

Smiley

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

tell me anout it... Like I said I think its so obvious that no one would ever think to mention it...
Thanks heaps Johan, I can see this tripping me up some time in the future. How do you(all, the professionals) deal with this?
I assume that if a variable has been declared that there is a space in memory allocated for that variable, and in an eight bit bit machine that the memory allocated will be one eight bit block( ?? or does the micro treat an eight bit block as one memory location? ... cant remember) Anyway if I assign a value, say 0 to that variable, will the memory location associated with the variable have the binary equivelant value of 48?
If this is so (and sorry for ging on and on and on...) does one always need to subtract 48 ( '0' ) when you want to do something with the number that rquires it to be properly represented? Or is this more to do with the fact that we are gathering data from a keyboard which is an ascii source and that the -'0' must only be done at the data aquisition stage...

cheers
8)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Let's see if I can help a bit.

1) declaring a variable allows the compiler to generate code to handle it. If it's a static variable (always around), then it's probably given a space in RAM (data memory). If it's a local variable, then it exists as long as the routine it's in is valid, which means that it's in RAM, but probably tied up with the stack pointer. (too complicated to go into here, for the nonce).

Now as far as how much is reserved. Byte variables are 8 bits. Integers or words are 16 bits, integers are signed, words are not. Depending on the implementation, there might be such a thing as long integers (32 bits); which obviously take 4 bytes. So the amount of storage depends on the variable type, and how that type is implemented on your system.

There's a difference between the character "0" and a variable that has a value of zero.

A variable has a value that's intended to be interpreted as a binary number, thus 0 = 00000000 or as many bits as the type of variable allows.

A variable that has the value of '0' is an ascii character. It's the code that when typically put onto an LCD display, a CRT display, or printed yields the character '0' being printed.

The decimal value of '0' is 48, the hex value of '0' is 0x30 or 030H. The decimal value of 0 is just that, 0.

The -'0' that you saw in an earlier post was a way of converting the numbers 0-9 from an ascii source (i.e. 0x30 to 0x39) to a numeric value (i.e. 0x0 to 0x9).

Hope that this clears up things a bit.

Harvey

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you Harvey,
I understood the conversion part, but not in which context the two difirent forms exist, i.e when 0 ~~ 0x0, and when 0 ~~ 0x30.
I assume that all mathematical operations will produce meaningless results on the ascii version (0x30-39)
If I assign a variable A with the value of 0, would that mean 0x00, not 0x30. But for character input from a keybard, a keypress of 0 would result in 0x30? Likewise if I want to output the results of a mathematical operation to an lcd the internal value would have to be translated by 0x30?
Does this issue occur with ADC's etc?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A binary zero is 0 or 0x00. The ascii char zero is '0' with single quotes. A string with an ascii zero and a null for a string terminator is "0". I think its helpful to remember the computer deals with binary, the ascii is for the benefit of the carbon based operators. The computer is perfectly happy thinking about our decimal numbers in binary... our 32769 is his 0x8001. We need to tell him to print them out in our favorite format. After a while, we start using his format. Sort of a vulcan mind meld.

Imagecraft compiler user

Pages