Maker Pro
Maker Pro

So I missed a memo.....or three or four

Fish4Fun

So long, and Thanks for all the Fish!
I started playing with writing code for PCs back in the early 80's.....by the late 90's I had added AVR uControllers and a smattering of 8051 based uCs to my tool box....I still write/support some personal Apps for PCs in Visual Basic...I still write firmware for AVRs in ASM....I know I need to learn C, (but I am on the wrong side of 50 for learning too many more tricks and I am more than a little oppositional defiant)...There are times it would just be so much faster/easier to use a PC if there were just a simple/cheap way to embed it into the project.....

Well, it appears I missed the memo on the Rasberry-Pi revolution....I know, Hard to believe! What's more, I missed the memo on the whole .NetMF open source development package AND I missed the memo on the whole "gadgeteer" line of products.....and I now feel very confident I missed other memos....but I have been reading all day....doing my best to get caught-up.....

Sooo, having missed nearly half a decade of innovations in blurring the line between PCs and Embedded Controllers...I am in the market for a System-On-a-Chip based development board....WOW are there a lot of choices....The Rasberry-Pi 2B is cheap enough that I can't really think of a good reason not to order one.....but then there is the super-sexy CubieBoard4/Octa with more resources on board than several full-blown desktops I still have up and running and it isn't too much more than the Rasberry-Pi 2B ..... but it is likely going to be a bit less user friendly for someone torn between VB and ASM......

These two candidates are far from the only SOC development boards out there, but they seem representative of what's available.....I know there are some Intel based as well as other cores out there, but I have always kind of wanted to play with an ARM core....so unless there is good reason to look at something else I plan on sticking with an ARM core variant....Of course this begs the question of which OS to start with....and this, in-turn, begs the question of attempting to play with .NETMF.....or to simply take this sojourn into SOCs as the final straw that pushes me to learn C....but all of that is putting the cart before the horse......

I need/want to start playing with some variant of these Dev boards...and I am hoping for some insights into where to start....Ultimately the goal is rapid development of one-off embedded control systems....Nothing I have undertaken to date has even put a dent in an Arduino MEGA2560's resources...so increasing the resources two or three orders of magnitude would absolutely be about decreasing the development time and making user-interfaces more user friendly.....

So, by all means, please offer insights/suggestions/anecdotes/warnings and if you have a personal favorite board/platform PLEASE tell me about it:)

Thanks In Advance!

Fish
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
you probably also missed the memo on all the TI boards available in small quantities at low prices. Dave Jones did a review of one of them sooner time ago that might be worth a watch.
 

Fish4Fun

So long, and Thanks for all the Fish!
@*steve*......YEP! I missed THAT memo too.....Did more searching/reading....WOW....I feel sorta like Rip-Van-Winkle.....Ti is OBVIOUSLY feeling they missed the boat with the Arduino Explosion.....(or maybe it has just taken them this long to respond to the Intel Revolution back in the 1980's LOL!)....It would be an exciting time to be a young computer enthusiast!

Maybe you should create some sort of *sticky* thread reserved for mind blowing, revolutionary new products/technologies so us old farts can occasionally glimpse the present and not appear quite so out-of-touch when we pull our ostrich heads out of the sand to do a bit of reading, LOL......At the very least, if there are any other note-worthy revolutions from the last half-decade or so that stand out in your mind, please feel free to list them for me....I will diligently ferret out the details, brush out some cobwebs and store the information for future use :)

Thanks!

Fish
 
as the final straw that pushes me to learn C....
That is where I am at, trying to figure out how C interfaces with PIC processors. The Pi is neat too, but sometimes you just need a 60 cent chip to get the job done and a few lines of codes to make it happen. I am looking at some online courses in C and reading C Programming a modern approach to get a better handle on the coding side of things. What direction are you going to take?
 
That is where I am at, trying to figure out how C interfaces with PIC processors. The Pi is neat too, but sometimes you just need a 60 cent chip to get the job done and a few lines of codes to make it happen. I am looking at some online courses in C and reading C Programming a modern approach to get a better handle on the coding side of things. What direction are you going to take?
You could also check out PICBasic (Pro), from Micro Engineering Labs. A Basic language especially developed for PICs. Very easy to use.
 
You could also check out PICBasic (Pro), from Micro Engineering Labs. A Basic language especially developed for PICs. Very easy to use.
Hi Steve!
Unfortunately it doesn't cover one of the chips I am currently playing with. Otherwise it looks pretty interesting. Do you personally use it?
 
Hi Steve!
Unfortunately it doesn't cover one of the chips I am currently playing with. Otherwise it looks pretty interesting. Do you personally use it?
Yes, for the majority of my projects. I have a C compiler that I use when really necessary, or even smatterings of inline assembly, but PICBasic covers most of my needs.
You can also use C or assembly modules with PICBasic, then link them in.

I mostly only need to use PIC16F84s, 16F628s or 16F876s though. Never used any of the real big ones.
PICBasic provides 16-bit support even when using 8-bit micros, without having to manually put it all together, and I rarely need more than 16-bit. Also supports serial comms without a hardware serial port, too.
 
You can also use C or assembly modules with PICBasic, then link them in.
I am new to these devices and their programming, but I am starting to see that the offerings like mikro C, etc, are IDE's whose value is really built on the libraries of functions that they have developed. Am I correct in that thought or ? With PicBasic, how are the pins of the pic addressed?
 
I am new to these devices and their programming, but I am starting to see that the offerings like mikro C, etc, are IDE's whose value is really built on the libraries of functions that they have developed. Am I correct in that thought or ? With PicBasic, how are the pins of the pic addressed?
To set the pins as inputs or outputs:-
In this case, I'm setting pin 0 on Port B as output, and the rest as inputs.
TRISB=%11111110

Then to address that pin and set it high or low:-
PortB.0=1
or
PortB.0=0

Alternatively, assuming all the ports pins are outputs, you can address the entire port:-
PortB=%11011000
(Sets pins 3,4,6 and 7 high, all others low.)

Decimal values can also be used instead of binary, but I find binary easier in this instance.

Aliases can be used for the pins too, to make code more readable:-
LED var PortB.0
PBSwitch var PortB.1

If a pin is an input and I want to read it and set a LED on or off accordingly:-
if PBSwitch==1 then
LED=1
endif
 
Last edited:
Aliases can be used for the pins too, to make code more readable:-
LED var PortB.0
PBSwitch var PortB.1

This is what I was after. I find the ASM too cumbersome, it makes sense sometimes, but at other times its too confusing, so much simpler to assign a variable to the specific pin and toggle it as necessary. I noticed that you made mention of TRIS and Port which are assembly terms, does PicBasic still require accessing the chip via asm routinely or just to assign variables?

Thanks!
 
This is what I was after. I find the ASM too cumbersome, it makes sense sometimes, but at other times its too confusing, so much simpler to assign a variable to the specific pin and toggle it as necessary. I noticed that you made mention of TRIS and Port which are assembly terms, does PicBasic still require accessing the chip via asm routinely or just to assign variables?

Thanks!
Just the register names are used in PICBasic - they're still used directly in PICBasic without assembly routines.
Here's a link to the manual, if you'd like to check it out:-
http://melabs.com/resources/pbpmanual/

This is an old version of the manual, but covers all of the basics of the language.
 
Here's a simple code example I wrote a few weeks ago, renamed as .txt to enable uploading:-
 

Attachments

  • WirelessPIRDevice.bas.txt
    6.3 KB · Views: 99
Thank you Harald, I'll keep that in mind. When trying to upload the file earlier there wasn't an option for .bas files, so as you saw, I just renamed it .txt .
(And thanks, too, for deleting that annoying post earlier. I'll report any future ones that I see.)
 

Fish4Fun

So long, and Thanks for all the Fish!
I am glad we are on the subject of high-level programming of embedded devices.....it brings to light a philosophical problem I have had for a long time with learning/using C for uControllers.....I absolutely understand the advantages of access to libraries...."Simple things" like base-10/Ascii displays, 16/32 bit integer/floating point math.....just to mention a couple of the most obvious....but I can't shake the feeling of "loosing control" of timing critical routines.....Things like "toggling a pin" on an Arduino Mega2560 to create specialized communication protocols....in ASM this code is small and highly efficient, but the compiled code from C libraries for the same functionality seems to be plagued with inefficiency and "quirky" behaviors.....Intellectually I know that I could insert ASM routines in these special cases...AND that by refusing to learn C I am essentially "throwing the baby out with the bath-water"....but none-the-less it remains a sticking point....Which is more than a little odd because the WHOLE POINT of this post was that I had failed to notice the explosion of "embedded micro-processors" AND that it would be really handy to have a PC based interface for tasks that are simply too complicated to write in ASM....

My other problem with learning C is that so much of C is having a priori knowledge about existing libraries.....and knowing "how to use them"....what to modify for a particular target....when to use "A" vs "B" etc, etc.....Oh, and the whole "strict enforcement" of variable names PLUS the very odd (to me) "syntax & operators" ABSOLUTELY KILL my Dyslexia...as a simple example of what I consider to be needlessly cryptic syntax consider the following "example explanation" of the comma operator:
Code:
// Examples: Descriptions: Values after line is evaluated:
int a=1, b=2, c=3, i=0; // commas act as separators in this line, not as an operator
// ... a=1, b=2, c=3, i=0
i = (a, b); // stores b into i
// ... a=1, b=2, c=3, i=2
i = a, b; // stores a into i. Equivalent to (i = a), b;
// ... a=1, b=2, c=3, i=1
i = (a += 2, a + b); // increases a by 2, then stores a+b = 3+2 into i
// ... a=3, b=2, c=3, i=5
i = a += 2, a + b; // increases a by 2, then stores a to i, and discards unused
// a + b rvalue. Equivalent to (i = (a += 2)), a + b;
// ... a=5, b=2, c=3, i=5
i = a, b, c; // stores a into i, discarding the unused b and c rvalues
// ... a=5, b=2, c=3, i=5
i = (a, b, c); // stores c into i, discarding the unused a and b rvalues
// ... a=5, b=2, c=3, i=3
return a=4, b=5, c=6; // returns 6, not 4, since comma operator sequence points
// following the keyword 'return' are considered a single
// expression evaluating to rvalue of final subexpression c=6
return 1, 2, 3; // returns 3, not 1, for same reason as previous example
return(1), 2, 3; // returns 3, not 1, still for same reason as above. This
// example works as it does because return is a keyword, not
// a function call. Even though most compilers will allow for
// the construct return(value), the parentheses are syntactic
// sugar that get stripped out without syntactic analysis

Taken w/o permission from: https://en.wikipedia.org/wiki/Comma_operator

My poor little brain goes into a tailspin when I attempt to read much less attempt to write this type of cryptic concatenation of syntactically correct code.....I much prefer:

Code:
int a=1, b=2, c=3, i=0;

Replaced With ==>

dim a as integer
dim b as integer
dim c as integer
dim i as integer

a = 1
b = 2
c = 3
i = 0
-----------------------------------------------------------------------
i = (a, b); // stores b into i  
Why Not Just use ==>
i = b
-----------------------------------------------------------------------
i = a, b; // stores a into i. Equivalent to (i = a), b;
Again ==>
i = a
-----------------------------------------------------------------------
i = (a += 2, a + b); // increases a by 2, then stores a+b = 3+2 into i
How about ==>
a = a + 2
i = a + b
-----------------------------------------------------------------------
i = a += 2, a + b; // increases a by 2, then stores a to i
a = a + 2
i = a
-----------------------------------------------------------------------
i = a, b, c; // stores a into i, discarding the unused b and c rvalues
Really? ==>
i = a
-----------------------------------------------------------------------
i = (a, b, c); // stores c into i, discarding the unused a and b rvalues
Really? ==>
i = c
-----------------------------------------------------------------------
return a=4, b=5, c=6; // returns 6, not 4, since comma operator sequence points
I don't even understand this....but how about ==>
c = 6
return = c
-----------------------------------------------------------------------
return 1, 2, 3; // returns 3, not 1, for same reason as previous example
ditto ==>
return = 3
-----------------------------------------------------------------------
return(1), 2, 3; // returns 3, not 1, still for same reason as above. This
// example works as it does because return is a keyword, not
// a function call. Even though most compilers will allow for
// the construct return(value), the parentheses are syntactic
// sugar that get stripped out without syntactic analysis
ditto ==>
return = 3
-----------------------------------------------------------------------

I DO understand the need for syntactically correct statements in writing code....I can even appreciate the need for some "shorthand" but the subtlety and nuances associate with C make my head swim.....and my attempts at learning C to date have been stymied by the (again, TO ME) unintuitive syntactical caveats.....

So chopnhack...what direction am I going in my pursuit of C for uControlers? I am steadfastly resolved that my life would be much easier if I weren't so Opositional Defiant....LMFAO....In analogy, I am really, really thirsty, but if you drag me to the watering hole I swear I won't drink a drop! :) lol ..... hehehe, as a side note...people say English is a very difficult language to learn and yet I know more than a few absolute idiots who speak it remarkably well...sadly those idiots don't have anything interesting to say.....Obviously I don't (yet) "speak" C....I am undecided on the implications associate with learning it....would I still be an idiot?...or perhaps I could be an articulate, well-rounded, more complete idiot :)

LOL! Have Fun!

Fish
 
Last edited:
Top