Jump to content

Arduinos


system 4-50

Featured Posts

7 minutes ago, Jen-in-Wellies said:

So just like lock down 3 then.

 

I wonder if the lockdown has caused more people to get involved with programming micro controllers in C and its this that has led to the national increase in alcohol consumption? ?

  • Haha 1
Link to comment
Share on other sites

2 hours ago, nicknorman said:

I bought a C book in about 1990. Quite fat and very dull and impenetrable. And the book wasn’t much better. Absolutely zero progress with trying to make any sense of it. Last year, ie 30 years later, I thought I really ought to give myself a good slapping and get a grip, so I bought books called “C programming in easy steps” and “C for Dummies”. The Dummies book was truly awful, irritating, patronising and hopeless. The “easy steps” book was quite good, has most of what you need reasonably concisely.

 

But the real trick is that you need to have a project or at least something to actually programme on. You can’t just read a book about it because it won’t mean anything.

 

I may go with this one as it's for absolute beginners.

 

61XlLatziOL.jpg

Link to comment
Share on other sites

5 hours ago, buccaneer66 said:

Are there any good books for those who haven't used C before to help learn it?

I have tended to use Arduino programming books.  Beginning Arduino: Second Edition (Technology in Action) Paperback – 18 Sept. 2013.  by Michael McRoberts is one.  Or I look for a sketch on the internet which looks like what i want to achieve.

 

I tend to deny that I know how to write programs in C....   I have done more programming in Python of recent, but find the skills adapt - I just need to remember the syntax.  It is also why I am looking at the Raspberry Pi Pico as this is programmed in Python.  I find writing a program that works in Python is easier. 

 

I hope this helps! 

Link to comment
Share on other sites

1 hour ago, Amos Moses said:

I have tended to use Arduino programming books.  Beginning Arduino: Second Edition (Technology in Action) Paperback – 18 Sept. 2013.  by Michael McRoberts is one.  Or I look for a sketch on the internet which looks like what i want to achieve.

 

I tend to deny that I know how to write programs in C....   I have done more programming in Python of recent, but find the skills adapt - I just need to remember the syntax.  It is also why I am looking at the Raspberry Pi Pico as this is programmed in Python.  I find writing a program that works in Python is easier. 

 

I hope this helps! 

 

Geek Alert!

 

Python is very popular buts its interpreted and dynamically typed which helps make it easy to use but also makes it pretty useless for precise engineering stuff like Arduino..

 

Some of this thread discussed the need to define unsigned rather than signed integers and Python just has no real concept of this sort of thing.

 

............Dave

Link to comment
Share on other sites

6 minutes ago, dmr said:

Python is very popular buts its interpreted and dynamically typed which helps make it easy to use but also makes it pretty useless for precise engineering stuff like Arduino..

The new Raspberry Pi Pico is programmable in Micro Python as well as C. I've no idea what micro python is and not played with a Pico at all yet. Can it get round the sorts of problems you've described for python?

Edited by Jen-in-Wellies
Link to comment
Share on other sites

1 minute ago, Jen-in-Wellies said:

The new Raspberry Pi Pico is programmable in Micro Python as well as C. I've no idea what micro python is and not played with a Pico at all yet. Can it get round the sorts of problems you've described for python?

 

I did have a very quick look at that. There are various things available to overcome some of the weaknesses of Python but to me it seems a bit wrong to start with something thats not quite right (or totally wrong) and fix it weaknesses, better just to start with the right stuff.

 

I suppose really its almost a total new language that just happens to use the Python syntax? The bloke in Israel who produces the B4A stuff has produced a version that lets you program the Arduino in BASIC.

 

Much as I dislike C it is exactly the right language for programming micro controllers.

 

...............Dave

  • Greenie 2
Link to comment
Share on other sites

8 hours ago, buccaneer66 said:

Are there any good books for those who haven't used C before to help learn it?

My "go-to" Arduino book is "Programming Arduino - Next Steps" by Simon Monk. He also has an entry level book "Programming Arduino - Getting Started with Sketches".

https://www.amazon.co.uk/Programming-Arduino-Next-Steps-Sketches-ebook/dp/B07J1DNF5V/ref=sr_1_6?crid=22WMD3TIW6IBZ&dchild=1&keywords=simon+monk+arduino&qid=1612383623&sprefix=Simon+Monk%2Caps%2C167&sr=8-6

Link to comment
Share on other sites

1 hour ago, eightacre said:

Simon Monk. He also has an entry level book "Programming Arduino - Getting Started with Sketches".

I also have that one and still find it a bit heavy in places, but a useful reference book once you have got going. As was said before, you absolutely need to have the device working in front of you to learn anything. I have also got "Programming Interactivity" by Joshua Noble on loan from the library but it is far too advanced for me, and I don't think I have got anything from it yet, but will hang on to it for a while.

 

If you have the internet freely available there is a series by Paul McWhorter on Youtube which is at the other end of the scale, ie very very slow, but he does a very professional presentation and that might be the way forward for an absolute beginner like me: https://www.youtube.com/playlist?list=PLGs0VKk2DiYw-L-RibttcvK-WBZm8WLEP  They are a very recent production but I found his introductions very tedious after a few.

 

I have got to number 18

 

Link to comment
Share on other sites

3 hours ago, dmr said:

Much as I dislike C it is exactly the right language for programming micro controllers.

 

...............Dave

 

Totally agree - despite its various weirdnesses, C is great for interacting directly with the hardware. Things like union and different length bit fields in a structure which seem totally pointless when you read about them, suddenly become super-helpful. The trouble is that with Arduino, you are not really interacting directly with the hardware, they have added all those custom functions to keep you away!

 

I just finished a PIC project, reading in some NMEA sentences over RS232, picking out the one with the label I want, checking the checksum, parsing that to get a couple of parameters in the comma-delimited sentence, and using that to make beeping noises at various rates (it is a FLARM interface to a glider tug radio, beeping, which is a collision warning, to be injected into the aux input of the radio). Interrupt driven and using 3 timers + a watchdog. No use of someone else's library routines (apart from the MCC configuration utility), all my own work. I think it has taken perhaps 4 days to perfect despite being a relative newby to C. Doing it in assembler would I'm sure have taken weeks.

Edited by nicknorman
Link to comment
Share on other sites

10 minutes ago, nicknorman said:

Totally agree - despite its various weirdnesses, C is great for interacting directly with the hardware. Things like union and variable length bit fields in a structure which seem totally pointless, suddenly become super-helpful. The trouble is that with Arduino, you are not really interacting directly with the hardware, they have added all those custom functions to keep you away!

 

There's always assembler.

Writing assembler was my first ever proper job and I vowed never to do it again (and almost succeeded), but don't let me stop you having a go ?

What would be quite interesting is to see the compiled code from C output in assembler but I don't think that can be done. You can look at the Hex but that's a step too far.

 

.................Dave

Link to comment
Share on other sites

16 minutes ago, dmr said:

 

There's always assembler.

Writing assembler was my first ever proper job and I vowed never to do it again (and almost succeeded), but don't let me stop you having a go ?

What would be quite interesting is to see the compiled code from C output in assembler but I don't think that can be done. You can look at the Hex but that's a step too far.

 

.................Dave

My first ever job was writing microcode for a bit slice CPU which ran to 4 boards! I enjoying writing the floating point maths routines. I think!

 

I did quite a lot in 6809 and 8051 assembler in the 80s and 90s, they were both microprogrammed microcontrollers so the instruction sets were pretty comprehensive. Not like the RISC PICs which have a bit of a weird and limited instruction set - I did 1 project in PIC assembler but sensibly moved on the C now!

 

Actually the PIC IDE has the ability to show the programme memory both as machine code and assembler, and it labels the start of functions etc, but trying to fathom what the C compiler is doing seems pretty daunting.

Edited by nicknorman
Link to comment
Share on other sites

8 minutes ago, nicknorman said:

My first ever job was writing microcode for a bit slice CPU which ran to 4 boards! I enjoying writing the floating point maths routines. I think!

 

I did quite a lot in 6809 and 8051 assembler in the 80s and 90s, they were both microprogrammed microcontrollers so the instruction sets were pretty comprehensive. Not like the RISC PICs which have a bit of a weird and limited instruction set - I did 1 project in assembler but sensibly moved on the C now!

 

Actually the PIC IDE has the ability to show the programme memory both as machine code and assembler, and it labels the start of functions etc, but trying to fathom what the C compiler is doing seems pretty daunting.

 

Floating Point maths is something else. I briefly cared for a mini computer with a wire wrapped and microcoded FPU.

For a micro controller the Arduino does a pretty good job with floating point.

 

Hopefully we can all go boating again later this year otherwise CWDF might turn into a geek forum ?

  • Haha 1
Link to comment
Share on other sites

13 hours ago, dmr said:

 

I did have a very quick look at that. There are various things available to overcome some of the weaknesses of Python but to me it seems a bit wrong to start with something thats not quite right (or totally wrong) and fix it weaknesses, better just to start with the right stuff.

 

I suppose really its almost a total new language that just happens to use the Python syntax? The bloke in Israel who produces the B4A stuff has produced a version that lets you program the Arduino in BASIC.

 

Much as I dislike C it is exactly the right language for programming micro controllers.

 

...............Dave

Your comments are duly noted both you and Jen-in-Wellies are right.  I am just telling you my experience and why I referred to Arduino books and not C programming books.  My Arduino Library is Practical Arduino, Beginning Arduino, Exploring Arduino, Arduino: A Quick Start Guide, Getting Started with Arduino and Arduino Cookbook.  My Python library is Automate the Boring Stuff with Python. 

 

To programming theory, lots of the best put rough code together to prove a concept and then refine it.  For the project being discussed here, the Pico may just work and be simpler to program.  I do not know - I have one sitting here but never started it up.  The point is getting programs that work first.  So, I use wordprocessors - not my own text editor, for example.  We all take shortcuts.  I have written programs for work that save time and we use daily - but in Python.  They work and that is the point. 

 

The final issue is learning to program.   If you can program, you can learn different languages.  I have been programming since 1979, as a hobby, but never got to learning C.  I program Arduino's though.  If you can learn C, go for it - I would not discourage you.  I am just saying what I do.   

7 minutes ago, nicknorman said:

For some reason this topic stopped showing up on VNC, I did wonder if it had been deleted for being too polite and lacking argument and personal attacks, but no it’s just hiding from VNC (maybe this post will un-lurk it).

This is showing up for me on the forum.

Link to comment
Share on other sites

1 hour ago, Amos Moses said:

To programming theory, lots of the best put rough code together to prove a concept and then refine it. 

 

There is also a wealth of information on Github: https://github.com/topics/arduino

Whatever project you are thinking of, there is usually someone else attempting something similar.

Link to comment
Share on other sites

14 hours ago, nicknorman said:

My first ever job was writing microcode for a bit slice CPU which ran to 4 boards! I enjoying writing the floating point maths routines. I think!

Out of curiosity, AMD 2900, Intel 3000, one of the TI ones or something even weirder?

Link to comment
Share on other sites

Just now, Batavia said:

Out of curiosity, AMD 2900, Intel 3000, one of the TI ones or something even weirder?

It was my first job out of Uni and it was 1977 so I don’t recall exactly what it was but I think the design was in house.  There was a bit slice ALU chip and a lot of other separate glue chips. This was at British Aerospace for the computer running a Rapier missile defence system, field standard B IIRC. Everything was mil spec, radiation hardened, Emc - pulse shielded etc.  We think things are bad now with Brexit and Covid, but in those days we were one mad tyrant with an itchy button finger away from global nuclear annihilation!

Link to comment
Share on other sites

18 minutes ago, system 4-50 said:

I hate little-endian microcomputers! Just what is the point of putting the cart before the horse! I hate little-endian machines…. I hate little-endian machines… rant rant...

 

But 90% of the time C will protect you from such evil, you just define integers (16 or 32 bit) and don't have to worry about what goes on inside them.

 

The thing that upsets me with computer stuff is having to count from zero rather than one, its not right, if you win a race then you come first, you don't come zeroth ?

 

...........Dave

Link to comment
Share on other sites

25 minutes ago, system 4-50 said:

I hate little-endian microcomputers! Just what is the point of putting the cart before the horse! I hate little-endian machines…. I hate little-endian machines… rant rant...


I’ve  recently written some code to interface with Victron’s VE.Direct hex protocol. They give the labels for the various parameters which are transmitted as ascii representations of hex. So for example the label for current is 0xED8F. Which is fine, until they go on to mention that the bytes are sent and received little-endian so you have to send 8FED. How stupidly annoying is that?! Why not just say the label is 0x8FED and leave it at that!

2 minutes ago, dmr said:

 

But 90% of the time C will protect you from such evil, you just define integers (16 or 32 bit) and don't have to worry about what goes on inside them.

 

The thing that upsets me with computer stuff is having to count from zero rather than one, its not right, if you win a race then you come first, you don't come zeroth ?

 

...........Dave

Ah yes the old array trap. char array[7]; which actually has array[0] to array[6] and if you write to array[7] it’s a disaster!

Edited by nicknorman
Link to comment
Share on other sites

2 minutes ago, nicknorman said:


I’ve  recently written some code to interface with Victron’s VE.Direct hex protocol. They give the labels for the various parameters which are transmitted as ascii representations of hex. So for example the label for current is 0xED8F. Which is fine, until they go on to mention that the bytes are sent and received little-endian so you have to send 8FED. How stupidly annoying is that?! Why not just say the label is 0x8FED and leave it at that!

 

Where did you find the specs for the Victron Hex communications? I searched but could only find the less powerful ASCII stuff.

 

...............Dave

Link to comment
Share on other sites

1 minute ago, nicknorman said:

On the web somewhere. I’ll email it to you.

 

Thanks

 

and VB6 was (still is) a good language, you can choose whether arrays start at 0 or 1, or even specify it for individual arrays:

 

Dim AAA(1 to 10) as long

 

.........DAve

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.