Max (the Magnificent) Maxfield (@MaxMaxfield)
Very interesting -- thanks for sharing this -- as you say, this compiler is a smart beast (I fear it's creators are laughing at me :-)
Someone else said something similar -- this was one of my reasons for doing tests 0, 1,
and 2 -- to determine the overhead of the if() and else-if() tests so I...
I had started to move this way -- actually using the result as part of a Serial.print() -- because that way the compiler knows I want a result -- but it was still...
I see what you mean -- this was one of my reasons for doing tests 0, 1, and 2 -- to determine the overhead of the if() and else-if() tests so I could subtract them...
Do I look like the sort of man who can make an array of pointers? Now I'm going to have to go and re-read my book on "Understanding and Using C Pointers" https://www.amazon.com/gp/product/1449344186...
It's me again (sorry). As a reminder, I'm a hardware design engineer, so my software knowledge is somewhat limited. I'm using the latest Arduino IDE 2 and I'm being...
Thanks Jacob -- I was actually going to call you about this, but I know how busy you are so I thought I'd post the question here -- and lo and behold, you responded...
I'm confused. I read that Visual Studio (VS is an IDE. I also read that Visual Studio Code (VS Code) is a source code editor (is this the editor used in VS?)But...
I'm a bit confused -- I recently started playing with servos. In the book "Motors for Makers" https://www.amazon.com/dp/0134032837 it says that 1.5ms pulses always...
Hi there -- this is awesome -- thanks so much for taking the time to write this up -- I really appreciate it -- Max
I'm sorry that this isn't related to embedded systems but I'm in a bit of a pickle. I have to write a test specification document for a vibration test for motorcycle...
Thanks Matthew -- I'm passing these responses on to my friend -- I'm hoping he will join Embedded Related and continue the discussion here.
Thanks Steve -- I'm passing these responses on to my friend -- I'm hoping he will join Embedded Related and continue the discussion here.
Thanks Jacob -- I'm passing these responses on to my friend -- I'm hoping he will join Embedded Related and continue the discussion here.
I just heard from one of my contacts on LinkedIn – he sent me the following message (he told me I can share it) asking for advice:--------------------------So,...
Hi there -- can you explain in simple terms how – if you are
feeding an analog signal into say a 4-bit analog to digital converter (ADC) with 16
digital output...
I have a bit of a conundrum -- when playing with LEDs, should we first modify brightness and then apply gamma correction, or should we apply gamma correction first...
Your knee-jerk reaction may be that this is not embedded related -- but even embedded designers have to have a hobby -- and I'm currently working on a project that...
As you say, since we are using only byte-size fields in out union, this does work well. I'm just happy to have learned a new trick :-)
Hi Mr Firmware -- I totally agree regarding the naming -- personally I use Upper Camel Case for global variables and Lower Camel Case of local variables -- my example...
This is based on some questions I posed (and you all answered) before. Suppose I have declared NUM_SETTINGS to be equal to 3. Let's also assume I've defined FRED...
Hi John -- Thanks so much for your response -- do you mind if I quote your response in a column I'm writing?
I'm just trying to get a feel for things here. I'm a hardware design engineer by trade. I'm familiar with the concepts of formal verification with regard to designing...
As always, I'm really sorry to bug you with a simple question (simple to you, not to me) -- I'll try to make this the last one for a while. I'm using an Arduino...
"Another approach [...] is the
Fletcher's Checksum" I've never heard of that -- now I'm excited to learn something new -- I will Google that as soon as a get a...
"Don't go back to the dark pre-C99 days." But they were so exciting -- so much was unknown -- porting a program was full of mystery and adventure LOL
Hi Mr. Firmware -- this is great feedback -- thanks so much for taking the time to share. One thing I'm going to note in my column is that my project is a simple...
Re memcpy() not working -- that's what I thought (in my own slow "hardware-brained" way :-)But although I can understand your code, I fear it would be tricky for...
Most of the values in DefSettings are constant apart from the Checksum value -- speaking of which, I just posted another question (I'm sorry): https://www.embeddedrelated.com/thread/13888/why-crc-with-epromApart...
On the one hand I feel guilty and embarrassed about asking all of my simplistic questions, but I always end up learning so much here.This relates to my previous...
But what if I want to copy the data from DefSettings to the EEPROM -- or from the EEPROM to WrkSettings? For the former (with my union), I was planning on using: ...
It's heartening that I was almost there the first time -- all I needed was (a) Bob11's slight tweak and (b) a compiler that worked LOL. But it's awesome that VadimB's...
Hi Eric -- (a) I love this solution and (b) I wish I was more proficient at C/C++The problem is that I'm writing an article about a display project I'm building...
Hi Dilberto -- VadimB came up with a solution that works:Settings DefSettings = { .vds = { .vdMagicNum = 0x42, .vdVersionNum ...
I tried making your suggested change as shown below -- but I'm still getting the errors shown below that (sad face)#define NUM_SET_BYTES 10typedef union{ ...
I'm using whatever compiler is in the Arduino IDE version 1.8.13 The errors I'm getting are:Test_01:33:9: error: expected primary-expression before '.' token ...
I'm afraid I've reached the limit of what I can wrap my brain around with regards to initializing a union -- any help here will be very gratefully received.As you...
You make my little bitmap sound so pedestrian -- in reality I'm working with a 29-segment display -- but I see what you mean :-)
I love the way everyone comes up with different solutions to this stuff -- instead of EL, I could use NA (not applicable) or NU (not used). Thanks for the suggestions...
The reason I'm confused is when we use "one-hot" in the context of state machines, we can only have one 1 -- but in the multi-segment display example, although we...
Here's another question that just popped into my mind. Suppose we have a state machine with four states, we could represent these states using two registers and...
What about declaring a struct with the number/counter and an array of values -- then declare an array of these structs -- it would use the same amount of memory...
That's a great point (not needing the number if we're using -1 to save space) -- thanks for sharing.
Thanks Keith -- it's always these little things that niggle me and make me think "I wonder what a professional would do?" :-)
Hi there -- sorry as always to bug you, but I have another noddy (beginner) question as follows:Suppose I want to have an array that looks something like the following...
I love having lots of Flash and RAM ... but I also used to enjoy working within tight resource constraints.
"In embedded applications however, if there is some knowledge of
likelihood, the conditions most likely to occur should be tested first
as this will result in...
Hi there -- on the one hand I totally agree -- on the other hand, I'm trying to stay prepared in case I fall through a time-slip and find myself circa 1950 in which...
I just received an email from someone saying that his commercial coding experience started with a programmable calculator with 512 bytes of memory -- he wend on...
"Max, you asked for some cunning tricks to increment."I was hoping I'd be able to understand them LOL
Hang on, you can say ++++ ?Does that mean you could say:--Fred++++;But the prefix works different to the postfix -- so if I were to say:Bert = --Fred++++;I'd end...
"The AVR Compiler for ATMEGA chips almost always adds numbers by subtracting their -ve equivalent."Why?
Ooh -- I like the "Fred -= -1;"Re the (Fred >> 1) == (Fred / 2) -- is the "sometimes it won't" tied to the way different compilers treat signed integers --...
Hi there, sorry to bug you again, but I always learn useful stuff here -- again I'm writing a column -- and again I would appreciate the benefit of your feedback.Question...
Re your question -- my knee-jerk reaction would be 50% -- but I'm guessing you are going to explain the error of my ways :-)Re seeding with a value of 0 doing nothing...
I knew the Dilbert one -- I should have guessed xkcd would have something to say -- thanks for the link to random.org
"This is one topic where half-measures can be dangerous." I totally agree -- I'm just using them to control pixels wandering around my 12x12 ping pong ball array...
I'm going to be writing a short column on the Arduino's random() function. Remember that I'm a hardware designer by trade, so I'm fighting my way through the software....
My knee-jerk reaction is that 8-bit processors typically are more constrained in terms of memory and clock speeds -- also my understanding is that most of them don't...
Hi Dilberto -- If I had a choice, I'd make all the LEDs tricolor and give the user the ability to select the 0 and 1 colors (to accommodate people with color vision...
This is a follow-on to my previous post on Karnaugh Map minimizations https://www.embeddedrelated.com/thread/12579/karna...Only if you are interested, I just posted...
Hi Daniel -- K-Maps really are a useful tool -- re having "9" with LED (d) and "6" with LED (a), it would certainly be possible to do this -- I just used the same...
Hi Matthew -- I was on the fence about telling them about optimizing using 0s -- but based on your feedback I now think I should add that in as a sidebar, so thanks...
Hi Dilberto -- it's funny (well, not so funny) how much we forget if we don't keep on practicing with this stuff -- but it's also interesting how quickly it all...
Hi Kral -- as you say, that's the beauty of K-maps -- the fact that their rows and columns are ordered using as Gray codes -- I'm really impressed that Karnaugh...
It's funny how easy it is to forget things that you used to do all the time. I'm going to be writing a series of columns teaching digital logic fundamentals to newbies....
The LEDs are daisy-chained -- all controlled from a single pin on the MCU -- there are so many things you could do with this display -- but think what you could...
It's not that my mom dwells on the past -- but when she talks about the world she grew up in, it makes me realize how lucky we are today :-)
I was just telling my mom that I have been invited to give the keynote presentation entitled “Not Your Grandmother’s Embedded Systems” at the "Qt Goes Virt:...
Hi everyone -- take a look at this column I just wrote – if you could have an interesting, fun, or frivolous sensor-based project, then you may want to enter it...
I was just thinking about Digilent -- in addition to their Digital Discovery and Analog Discovery 2 tools, they recently entered the embedded measurement world with...
Well, you asked LOL:There's a relatively new FPGA company on the block called Efinix that have some very tasty devices for embedded applications (https://www.digikey.com/en/articles/techzone/2020/...)If...
Hi Stephane, Jim Turley and I have covered some interesting companies on EEJournal recently -- maybe you could get them to talk about their technologies -- I know...
We just posted Part 1 of what will be a 3-pard miniseries:How to Get an Engineering Job and Keep It (Part 1) https://www.adiuvoengineering.com/post/how-to-get-......
I've not heard this put quite this way -- but there is the Peter Principle -- a concept in management developed by Laurence J. Peter -- which observes that people...
Frig!!! And for some reason I can only edit the original post, but not the title of the thread -- give me strength!!! I'll email Stephane at EmbeddedRelated...
I love Dilbert cartoons -- I'll add this comment about using them to learn what not to do into my column :-)
This is great input Matthew -- I've seen some great managers and some awful ones in my time -- I will let everyone know when these blogs are posted -- Max
Hi there – this is a follow-on to my previous “How to Get and Keep a Job” question (https://www.embeddedrelated.com/thread/12258/how-to-get-and-keep-a-job)....
The way the French would tell this, the Hell would be English Food (but they still haven;t forgiven us for Agincourt (https://en.wikipedia.org/wiki/Battle_of_Agincourt...
Thanks Dnj -- this is all really good advice -- I'm already planning this as a three-column miniseries in my head.
Hi Waydan -- this is fantastic input -- thank you so much for taking the time to share it with me -- Max
Hi Dilberto -- thanks for your kind words -- they always say that you only discover what you don't know when you try to explain something to someone else. In this...
I'm going to be writing a
mini-series of blogs aimed at young engineers (or wannabe engineers)
about "How to get and keep a job" -- starting with how to decide...
A couple of days ago I posted a question regarding resistor tolerances (https://www.embeddedrelated.com/thread/12194/quest...)This was part of a series of columns...
"...perhaps dates to vacuum tube days when human labor was cheaper..." I wasn't trying to suggest that the grading was done by hand -- just that the 1% parts were...
One way would be to vary the price -- if you make 1% resistors 100X more expensive, then a lot of designers will decide that 5% is "good enough" LOL
Ns Antedeluvian noted in his comment above, I wasn't actually looking for a circuit, but this one is very interesting because it's a twist on one I documented in...
Thanks Aubrey -- I love your trimpot suggestion -- I fear that since so many people misunderstood my question, it's probably my fault for not articulating it well...
Actually, I did a 9-part mini-series on switch-bounce (see links below) -- I used to be a hardware fan -- then a software supporter -- now I love the debounce chips...
When I was starting out in engineering ~40 years ago, I was told that if a resistor manufacturer was making a bunch of 10K resistors, for example, then their actual...
I need to write a column about using hardware techniques to debounce switches -- if the circuit included an MCU we could do the debounce in software, so I'm looking...
"This is just an example of a bigger issue of the fuzzy terminology of our discipline."I'm guessing you aren't a fan of Fuzzy Logic LOL
"Of course, you can hold the viewpoint that 'everything is a state machine'."Are you calling my dear old mother a state machine? LOLIn reality, I would say that...
"No! The code you are showing is NOT a state machine. In fact, it is an antithesis of a state machine."Don't hold back -- tell me what you really think LOL.While...
Suppose we have a loop() function in an Arduino sketch (program) that looks like the following:void loop(){ digitalWrite(PinLed, HIGH); delay(1000); ...
Hi Manoweb -- thanks for your feedback -- On the one hand I'm tempted to go back and change everything to binary strings -- on the other hand, I have memory...
Thanks so much for taking the time to explain this stuff. Just one more question (for now LOL)Do I have to use both extern and const at the front of the program...
Hi Kocsonya -- thanks so much for your feedback. Re your points -- I'll take them in reverse order:2.
This is a really good point -- as you say, probably not significant...
I've been thinking (don't laugh; it's true). Would you agree that:-- For software developers creating applications to run on high-level systems like PCs, the keyword...
AWESOME!!! I just tried using the "extern" approach and it worked like a charm/ Every day I learn something new -- thank you for your sage advice!!!
Hi there, sorry to bug you with yet another stupid coding question (I R a hardware design engineer). This is related to my 12x12 ping pong ball array where each...
I just saw this part -- AWESOME -- will the first comparison stay there for awhile? (Can I link to it from a magazine column?)
Quick question -- so if I have an 8-bit signed int (int8_t) containing -128 (0x80), I know that if I cast this to a 32-bit signed int (int32_t), it will be sign...
Hi Jms_nh -- I am awed by the amount of work you put into this response -- thank you so much for all of this -- it's very much appreciated -- Max
Hi Cprovidenti -- when you say "...it is so self-evidently redundant..." I fear you are looking at this through the eyes of someone who already knows this stuff.I...
Hi Jmdhuse -- I'm with you -- I think it's best to write the code so anyone reading it in the future (and that could easily be me) can understand what it was I was...
LOL I'll have to remember that line. But you make a good point -- if the optimizer doesn't perform it's task, my superfluous statements could potentially impact...
This is just a quick question -- take a look at the following function:uint8_t GetBlue (uint32_t tmpColor){ return (uint8_t) (tmpColor & 0xFF);}I'm writing...
Good point, but the way the algorithm works is that the worst case will be to have GetRed() always return values of 255. In this case, we will have an intermediate...
I do like using parentheses to explicitly show what I'm trying to do -- and doing so can help a lot with precedence issues.
OK, in the following statement, tmpRed has been declared as a uint32_t. Also, I've modified the GetRed() function to return a uint8_t.tmpRed = ( ( GetRed(startColor)...
Sorry -- I should have said -- it's my pathetic attempt at C.The target processor dev board is a Seeeduino XIAO, which has a 32-bit Arm Cortex-M0+ (and which is...
Hi there -- sorry to bug you with a newbie question, but I'm a hardware design engineer, so software sometimes leaves me a bit confused.Can you take a quick glance...
Oooh, a "Nerds Hamilton" -- I can imagine the queues of nerds stretching down the street and round the corner. I just took a look on Amazon -- this book does look...
There's a "long long"? Where will this madness end?(Does every C compiler support the long long data type?)
Hi indigoredster -- thanks for the feedback -- it's a shame (a) these holes were left in the original spec and (b) they haven't been patched over the years -- Ah...
Do you know any examples of compilers that DO NOT shift copies of the sign bit in when performing a >> operation on signed integers?
I see "The quotient is rounded toward zero." I'm assuming this is because the rounding is basically a truncation operation, but this will make positive numbers...
Hi chaps and chapesses -- sorry to bug you again -- this is a follow-on to my previous question: What size variables are best for 8-bit, 16-bit, and 32-bit MCUs?...
Hi Jmford94 -- I think you offer sage advice -- I'm so glad I posted this question because the various responses have helped shape the way I go forward.
OMG There were THREE typos in each one (there aren't any now) -- for other readers, the way it was when I just went to look was: for (int8_t i = 0, i < 100,...
Are they "fast" because the compiler stores them in 32-bit words even though they are 8-bit and 16-bit values?
The problem here is that an int is a 16-bit quantity on an Arduino Uno, but a 32-bit quantity on an Arduino Due -- suppose I wrote the program using int on Due and...
Hi there – I have a conundrum rattling around my head. I once read that an MCU is most efficient when its working with its natural word width. On one level...
I've been using Visio for longer than I care to remember (must be more than 20 years) and I love it!!!
Hi Stephane -- Max here -- I'm based in Huntsville, Alabama, USA (I moved here from England for the nightlife -- that's a little Alabama joke right there :-)It's...
People are dying -- there's no way you can make that funny.There is no way you can make an ad using this topic that won't end up shooting yourself in the foot.Even...
If clicked, The privacy stuff stuff should pop-up in its own window so it can be dismissed without loosing any other info.
My mother asked me to tell you that you have a tremendous line-up of presenters, and she urges everyone to attend the talk by her first born son LOL
Good question -- I think one way to look at this is to consider what we expect to be coming our way application and technology-wise, and then "work back" to what...
Use this form to contact MaxMaxfield
Before you can contact a member of the *Related Sites:
- You must be logged in (register here)
- You must confirm you email address