So I think I might've fried my teensy 3.2 already.

Status
Not open for further replies.

Ros3

Member
I got my teensy 3.2 about 4 hours ago, and I think I already broke it.
So I was testing if the 3.3v signal would be enough to trigger my WS2811 LED strips (spoiler: it is, despite the conflicting info spread around), but ofc had the strips powered by an external 5v supply. I bumped the wiring, head a nice pop, and with a puff of smoke, the first LED in the stip died. Shame, but no use crying over it, they're only about 10c apiece (9.5 including shipping). However, now my teensy won't communicate with the computer at all. When I freshly plug it in, the pin13 led will flash very briefly, but that's about it. Then the white component next to the 3.3v pin - between 23 and AGND - gets REALLY hot. Now, I'm not very good with the hardware side of things (which is why I started getting into microcontrollers, so I could start learning), but iirc: a component getting super hot super quickly indicates it's shorting/is generally broken.
I have no clue what that component is (I tried looking it up, but I don't use EAGLE because it has never even crossed my mind to even think about manufacturing my own board.) but I would guess that it's pretty important to the operation of the device.
So what do you guys think? Did I already ruin the board? Soldering a new part is probably out of the question, I don't own the proper equipment to work with SMDs, and My soldering iron wasn't exactly designed for electronics (I bought the pre-soldered one for a reason...), nor do I even have a steady enough hand to deal with components that small. So I'm guessing I'm SOL and have to buy a new board? (not that I really mind, the teensy seems to be very promising in terms of how much flash and SRAM it has, and how powerful it is, and would be glad to support the project some more, and it's cheap compared to arduinos - not the knockoffs, though. Knockoffs are super cheap.)
 
<EDIT:> this post was to be on another thread . . . where it was applicable . . . Did-I-brick-my-Teensy-3-1?

Unless the Flash can be trashed by dropping voltage at some point during programming then it should be fine.

Unplug your Teensy - get the IDE ready to upload a Simple BLINK sketch with SERIAL USB print of "Hello World" or something - PRESS the Button then plug the Teensy in to the USB cable - pause a couple secs - release the button.

It should go back to programming normally - look at Serial Monitor for the text to display. Worst case - You might end up doing that more than once - maybe use a different USB port - but the Teensy has a stand alone programmer chip that can't get hosed without zapping it.

The Teensy is very robust - I've been handling a few ( bare boards with exposed pins ) for a year - including changing wires while under power - and not trashed one yet. Not recommended - just saying . . .
 
Last edited:
@Ros3 - sorry for the confusion - I read on my phone and the post order changed until I got to my computer.
There is a schematic at the store that will lead to the part - ...

I have not worked with WS2811's so I don't have any direct help . . . but I can say this (as a software guy) - not sure what your 'bump' did - as far as crossing up the voltages like that it may have leaked the smoke and fed something bad back to Teensy.

Last week I got a DotStar/APA102 strip that I put on the PJRC Prop Shield. That supports 5V Power + CLK + DATA as those strips call for it. Looking to disable the strip and assumed that I would just pull the power - of course I did this on a LIVE System running another sketch now - I got no smoke - but the strip did not power down - the 5V feeding the DATA/CLK lines was apparently used instead - I pulled another of those two wires - and still the LED's held their value ( as is the nature of the APA102 ) because it was living off the power on the last wire - with GND still attached. So at least with APA102's - there are direct connects it seems between the two data/clk lines and the LED's. Having split voltages on your 2811's set up some 1.7V of difference and is probably not something to repeat.
 
Then the white component next to the 3.3v pin - between 23 and AGND - gets REALLY hot.

That's the PTC fuse. It means something is drawing massive current.

If anything else is still wired up to your Teensy, disconnect it. If you're lucky, something else might be drawing all that power and the problem will magically go away when it's disconnected.

If the problem remains with only Teensy connected, I'm afraid things are looking pretty bad. Your one last chance might be if the voltage regulator was blown, but perhaps the rest survived (this is unlikely, but a few people have had this happen after a terrible "magic smoke" mistake). To try that, get a 3.3V regulated power supply and try powering the board by connecting directly to 3.3V and GND. Be careful, because if Teensy is shorting out and if your 3.3V power supply can deliver a lot of current, the chip will probably burn. But if you're lucky, the board may spring to life and you can at least use it with a 3.3V power supply.
 
That's the PTC fuse. It means something is drawing massive current.

If anything else is still wired up to your Teensy, disconnect it. If you're lucky, something else might be drawing all that power and the problem will magically go away when it's disconnected.

If the problem remains with only Teensy connected, I'm afraid things are looking pretty bad. Your one last chance might be if the voltage regulator was blown, but perhaps the rest survived (this is unlikely, but a few people have had this happen after a terrible "magic smoke" mistake). To try that, get a 3.3V regulated power supply and try powering the board by connecting directly to 3.3V and GND. Be careful, because if Teensy is shorting out and if your 3.3V power supply can deliver a lot of current, the chip will probably burn. But if you're lucky, the board may spring to life and you can at least use it with a 3.3V power supply.

I was afraid that's what it looked like.
It seems my psu only goes as low as 4.5v, and my other one isn't so good at keeping steady (it bounces between 3.2 and 4.8 - not the safest for use in sensitive electronics)
Tried a 3v coincell. nothing. (figured it was better than nothing, also not scared to try stuff, because it's sounding like it's likely I burned it all out, so the chip's likely already burned, and I have to replace it anyways)
alright, thanks for your help. Looks like I'll just have to order another one. Real shame. I just wonder how something could've pulled too much power in the first place. sure, I had 5v going into the LEDs, but they were powered independently. the teensy was only connected by gnd and signal, and it was a 5 LED strip. maybe when that led blew it crossed power and signal? No clue. just gotta cut out that LED, and iunno: resister+diode between the signal?

so if I'm reading this right: the fuse isn't itself broken, but something else is, and is likely shorting it out and drawing all the current? Meaning that the chip (or something) is actually destroyed, not the fuse?

Again, thanks for your help. looks like it's just fried
 
Ros3 - read my anecdote - the LED's gnd + signal + 5v were possibly connected by the smoke if they are like the APA102's I had. When the LED less loose . . .
 
Ros3 - read my anecdote - the LED's gnd + signal + 5v were possibly connected by the smoke if they are like the APA102's I had. When the LED less loose . . .

yeah, I got that, and figured that happened anyways, it was a pretty violent pop (still wonder what caused it, because the power supply was at 5.01v, and the teensy was powered off USB, and the rest of them stayed lit (data line is fried though, have to remove that LED from the sequence), so power doesn't seem to be an issue. might've just been a faulty LED chip.
So would a diode in series hurt the signal line? that way power can't be fed BACK to the teensy (least not a lot until it hits the diode limit). I'm just not sure if a diode would "mush" or just not be fast enough to transmit the signal reliably.
 
a diode will further drop the voltage - so what's left of the 3.3v may no longer work at all. Unfortunate you "bumped the wiring" - as that isn't diagnosable . . . did voltage drop or a pin touch somewhere - and was it 5V, 3.3V or GND . . . I'd assume the 3.3V .vs. 5V differential within the LED unit could be enough to mess with stuff as it isn't meant to deal with that - and at least the APA102's are clearly internally "adjacent" wrt data/clk/power/gnd. It is even possible the LED output side when passing along the incoming 3.3V data uses 5V to boost the data to proper levels for the next unit and that first LED was being really abused doing a full 1.7V level shift? If you got it working again that might be an interesting this to scope out. But I wouldn't suggest that - just buy the PJRC Prop Shield - it seems it will drive NeoPixels as well as the APA102's with proper 5V signals.

But I retired from a software job - I just kneel and respect hardware (at least when computers are on the floor) as best I can and get along fine with it.
 
ah, but I use WS2811s, they don't have a clock pin, so I'm not sure if the prop shield would work (it probably would, tbh, and it has a lot of nice things. definitely something for me to check out). However, I do have a OctoWS2811 Adaptor board on the way. only problem is getting cat6 cables the right length (I know I can just buy bulk cable, but I know that I don't need 1000 feet of the stuff). Especially because I live in a small-ish town where "electronics" stores get away with 300+% markup. Need a 6 inch CAT6 cable? that'll be $15. It's semi-tempting to actually buy the bulk cable + connectors, and sell them for only 200% markup. pretty sure people would pay 25c/ft.
Off topic trailing there.
Point is: I was really just testing if it would work, had an unfortunate accident, and murdered my chip. Basically nothing really salvageable off the dead teensy, either. probably the pins, maybe the USB port. Don't have hot air gun (have a heat gun, would work in a pinch) so I can't steal any SMD components (not that I even know which ones work, nor would I have the ability to re-seat any of them) So I have 2 teensys coming, one will be attached to the octo board, one will be used for random projects. will likely get a breakout board for it (so many pins, so little space!). Also have a knockoff arduino mega (it was $5, and it looks like all they did was change the silk screen. also my next project will need a MINIMUM of 21 pins. Arduinos don't really do that until you get to the "go big or go home" boards, but I'm not willing to pay the "go big or go home" prices, when it's obvious the cost of the parts can be minimized to <$5 with shipping.

As an unrelated note about my project: I spent about 3 days writing a whole process stack protocall so that I could perform delay() operations without stopping ALL the code... and I just found the Arduino_FreeRTOS library. Shame my process stack'll be ripped out now, but hey, using other people's libraries makes my life so much easier (did I mention that I actually don't really understand how my LEDs are driven? the lack of a clock pin baffles me. I know it's possible, but it seems like it would be much more unstable.)

And I'm pretty much in the same boat (although I'm in the beginning of my career, not ending), I'm good at software. Hardware generally confuses me, and tends to be the weak link (pft, what kind of microcontroller can't take 120v AC? or: Why can't I just stick a wire to the thing and be done? what's with all this "protection"?!) Though that doesn't slop me from watching tons of videos from Clive (bigclivedotcom) and AvE
 
Before I wrote the PROP note I checked that Beta thread - they have worked for at least 9. The NeoPixel clock and data travel on the same wire - so it does get touchy. The APA102's update faster and have local memory so they persist - which is what made me unplug wires 1 by 1 only to see them persist most persistently. That persistence also allows ignoring them when they don't need changed so you can use SPI for other stuff.

1Ft CAT6 cables are common ($3 for 12" and twice that for 6" at newEgg.com with shipping). You could buy longer than needed premade and cut and solder the one end and plug the other. The time and frustration of making your own - at least until you've done a few - and bought the right tools - is painful (and then it helps to have a EE friend with a couple cable tester units he manufactured at work and mails to you for free). I've been chopping up my current roll of CAT6 for Teensy wires - a foot a month will last a long time providing an infinite number of 8 colored wires.

You should spend some time scanning the PJRC web site and Forum . . . Look at ElapsedMillis() and ElapsedMicros() - it takes just minutes to understand how to make them delay() free - you can probably cut and paste most of what you did in those 3 days. There is a lot to the Teensy courtesy of PJRC - with SerialEvent for pulling serial data {delivered courtesy of the FIFO 'processor' and kept clean by interrupts) and those Elapsed values and interrupts in sketch or on devices you can easily simulate multitasking depending on your hardware usage - and not have to learn another environment that will diminish much of what PJRC and the forum here provide.

There are a couple breakout board for Teensy that make it easy to solder and expose the under pins - they are posted around. Two from OSH are:: BreakOutBoard_3 and ConnectorBoard 2

I'm not really retired - just an 18 year vacation I started at 35 until I figure out what I want to do when I grow up.
 
Obviously I didn't see your code - but the ElapsedM's are low overhead and ever increasing - just set them (individually and independently) back to zero and wait for them to hit your trigger point again. You can run on one and step through with a state variable for changing trigger values or run multiple in parallel to suit your needs. Accurate timing and the processor does all the math overhead quite efficiently - thanks to Paul.

Going to RTOS is a whole new paradigm - and I'm not sure the coolest stuff here works there.

I played with AtTiny before here and some UNO/Mega/Digix/(Due like)/redboard/pro/mini - After Teensy speed and the support here I won't bother. I have quite a few Teensy's waiting for work at least 10 powered up doing something at one time (touch display, 4 on ESP8266) or another and a couple in wrapper- but a couple dozen of those slow&weak AVR's never unwrapped.

I got a couple of the TallDog breakouts (your link is broken) - and some of the others - so far I only used one of the connector boards as I have enough pins so far.

When interrupt code is working on Teensy it is seamless and harmless as long as it can get in and out with the needed data - it is programming that where it gets tricky - most of that has been handled. I wrote a handler for the touch display interrupt pin - days of petrified fear before I started, more lost days over thinking it then a solution in under 100 lines in my sketch - put in place where it belonged in the library after seeing it (mostly) work and the net was 20 lines of code to set a flag to save SPI cycles from polling until a touch was registered on the INT pin - trivial and good improvement - and I got the final bug out when I was in the library.

RTOS will be nothing but interrupts as with a single core it can't do two things at once - but takes advantage of fast capable hardware and hope things go well as it rocks the world a few x thousand times a second pretending - adds overhead and complexity and will break some things.

Yes, local cables are expensive and not stocked much - UPS/NewEgg/Amazon is great.
 
Because mobile websites suck, I deleted my post (every button depressed the delete button instead...) So here it is again:

Yeah, I know CAT6 cables are easy to get online (monoprice has 6 inch ones for ~$2.50 shipped) I was just lamenting over how expensive they are locally for me.
That actually sounds pretty good. Cat6 in bulk is cheaper than what I can get locally (9c vs 15c, and 8 wires vs 3), so it may be worth it just to rip out the internal wires.

I fully understand how to make it delay() free, the problem was that I need it to do many many steps with specific timing between each step, but a different command each step. Basically: it's a lot of work now to save work/from spaghetti code later. The underlying principle of my stack library is checking the time passed, and verifying that anything that needs to be run NOW is ran now, but everything else is thrown back into the stack, and the library sleeps for a cycle. But also I've heard some very bad things about interrupts if you're not careful, because it really does just jump out and do whatever else without telling you. and: again: prebuilt libraries are the best. why reinvent the wheel? (i mean, other than to understand how it works, but I'm not terribly interested in the nitty-gritty of the project. Just seeing if it would really work as I want it to. and if it works, I'll likely never delve deeply into it again (even though I already have plans for later revisions if I feel like making it nicer)
as far as I understand it so far (not terribly deep yet), RTOS is basically another library, it's not a new environment (I rather like the arduino environment. For all the things I hate it for, it makes programming the boards super straightforward)

I was looking at https://www.tindie.com/products/loglow/teensy-31-breakout/, personally, but it looks like CPT's that you linked is almost functionally identical, would cost about the same to get printed (would get 3 for that cost, though), ignoring shipping.

well, I mean if you can afford to do that, that's great!

a side note on the cheap mega clone: it just arrived. Arduino didn't want to recognise it at first. windows grabbed the proper drivers (because they actually replaced the FTDI chip with a cheap WCH? brand, so arduino by default can't talk to it) surprisingly, and it seems to work just fine. Haven't stressed it yet, though.

Silly me, arduinos have an inbuilt 3.3v output. duh. nope. chip is dead it would seem. un/powering it made windows recognise SOMETHING was there, but never pulled it up. also the chip gets quite warm now, too. probably dead. Didn't kill the arduino clone, though. didn't even freeze. Although the default code on there was constantly saying it was receiving serial data. weird. Didn't think to dump it before I had written over it.
 
Obviously I didn't see your code - but the ElapsedM's are low overhead and ever increasing - just set them (individually and independently) back to zero and wait for them to hit your trigger point again. You can run on one and step through with a state variable for changing trigger values or run multiple in parallel to suit your needs. Accurate timing and the processor does all the math overhead quite efficiently - thanks to Paul.

Going to RTOS is a whole new paradigm - and I'm not sure the coolest stuff here works there.

I played with AtTiny before here and some UNO/Mega/Digix/(Due like)/redboard/pro/mini - After Teensy speed and the support here I won't bother. I have quite a few Teensy's waiting for work at least 10 powered up doing something at one time (touch display, 4 on ESP8266) or another and a couple in wrapper- but a couple dozen of those slow&weak AVR's never unwrapped.

I got a couple of the TallDog breakouts (your link is broken) - and some of the others - so far I only used one of the connector boards as I have enough pins so far.

When interrupt code is working on Teensy it is seamless and harmless as long as it can get in and out with the needed data - it is programming that where it gets tricky - most of that has been handled. I wrote a handler for the touch display interrupt pin - days of petrified fear before I started, more lost days over thinking it then a solution in under 100 lines in my sketch - put in place where it belonged in the library after seeing it (mostly) work and the net was 20 lines of code to set a flag to save SPI cycles from polling until a touch was registered on the INT pin - trivial and good improvement - and I got the final bug out when I was in the library.

RTOS will be nothing but interrupts as with a single core it can't do two things at once - but takes advantage of fast capable hardware and hope things go well as it rocks the world a few x thousand times a second pretending - adds overhead and complexity and will break some things.

Yes, local cables are expensive and not stocked much - UPS/NewEgg/Amazon is great.

for tracking time, I actually just have one value keeping track of millis(), and when the last stack processing was done. if the stack item is marked as delayed, it also has a byte to say for how long, and if it hasn't passed, the delay is recalculated from the time it was processed, and it's thrown onto the stack again.
To be fair, I actually don't need millisecond (or god forbid, microsecond) accuracy, just enough that it looks the same to a human observer. Being a bit dirty here is fine. The stack can only ever hold 20 items anyways, shouldn't take long to process them.

I'm sure RTOS will break some stuff, but if it works how I think it does, it'll save me so much headache. I'll have to learn to use proper Semaphores (not really something I've done before. I would always have one thread that handled all of one type of processing, never had to check if something else was using it - except for in assembly. We don't talk about those days), but it seems simple enough. and as the other part of the project is going to take a LONG time (like a year, minimum. Saw someone able to smash something similar together in 4 weeks, but not up to the quality/complexity I'm striving for)

Yeah, I swapped the URL and text areas (should've guessed it was a straight HTML conversion).
Like I said: I'm gonna need 17 control pins, and 3 output pins to start, and then probably a good... 5 more outputs for the secondary stuff? That part isn't really set in stone yet. So the teensy should handle that fine. well, maybe 1 will handle outputs, and 1 to handle inputs, and have them communicate over serial, because the ws2811 board I'm using covers up a lot of the pins (all the underside ones) and uses 10 of the pins - granted it's able to drive 8 strips, so that's to be expected. Might just end up building my own voltage multiplier circuits for the final build. I believe I saw a 3-component setup elsewhere on here, although I do like the idea of an RJ45 interface: Compact, FLEXIBLE cables that are easy to replace even away from any hobby/hardware store (for an enormous price, ofc)

true, I'm sure I'm worrying over nothing, interrupts wouldn't really be a thing if they broke everything. if handled properly, it should be just like a processor jump, and the code never knows that it happens.
I'm sure RTOS will operate exclusively on interrupts, but it's interrupts I don't have to deal with. I know that microcontrollers are (USUALLY) single-core, so multiple jobs at once is purely an illusion caused by the OS swapping out different jobs.
Overhead was to be expected (the stack is actually the thing that made me outgrow the constraints of the arduino. TONS of overhead. Also set to optimising some display code. some of it is compressed to <5% of its original size, with absolutely no data loss (well that's a lie. I discard data that makes absolutely no difference in how it's perceived, and a few hundred lines of code can be omitted), so I saved a bunch of space there (although that would've been flash memory, not SRAM. I wasn't running out of flash.) And breaking stuff just means you're a programmer. It's par for the course that nothing works right the first time because you forgot a break; somewhere, or swapped i and j while working inside nested loops. Point is: I know I can do it myself, I've actually almost done it. but my way is also sloppy and I have to write so much extra code around it that I'm dreading rewriting some of the functions to handle it properly (I have 3 functions right now that do exactly nothing because writing a version without delays would be very difficult. I guess one of them could hog the whole CPU, it doesn't matter, but it'd be better if I could have other stuff running with it.). and it's one more thing I could learn by just throwing myself at it. worst case scenario: I have the source code managed by git, I just revert back to the current version. best case: I have a fancy new "OS" for my microcontroller projects.

I've found that electronic shopping should be online 90% of the time anyways. exceptions are like keyboards. At least go in to test them, then buy them for cheaper online!
 
A true RTOS "owns" the CPU and hardware and interrupts, etc. So it's not like an optional library for your app. "RTOS", in this context, means something like FreeRTOS (popular freeware) that has its preemptive scheduler enabled. Each task in such an RTOS has its own MCU stack (RAM). Devices that interrupt must have drivers that are RTOS compatible. Etc.
FreeRTOS has a non-preemptive scheduler option (cooperative scheduler). Much simpler because the running task will not be preempted by another task and so mutual exclusion is not needed between tasks.
Most any other true RTOS has at least preemptive scheduling. A novice not aware of RTOS stack-per-task/preemptive scheduler should read, study, and not just dive in uneducated.

Some use the term RTOS for things that aren't either of the above. Beware.

Personally, I never do an overall design that relies upon task preemption. I've done so for 20 years of embedded work on MCUs. But I learned these principles of RTOSes on "minicomputers" (in a rack).
Instead of RTOSes, I've learned to design using finite state machines (FSMs). Very simple code. Very easy to desk-check design and code as correct (verify). A "superloop" calls each FSM in turn. If the FSM has no work to do, based on flags set in ISRs and elapsed time, etc., the FSM just returns. Otherwise the FSM does some brief work and changes its state variable so that next time it's called, it behaves differently.
FSMs are elegantly simple.

So my advice to small MCU users like Teensy and the like, is to avoid RTOSes whenever possible, after an educated decision is made on "do I really need the complexity and the risk-to-reliability of an RTOS?".

There are some cases where an RTOS is prudent, for sure. Usually in quite complex systems and preemption is essential for, e.g., low latency in processing that must be done after an interrupt but is too lengthy to do in the ISR.
 
There are multiple flavors of RTOS available. I looked at several and found the learning curve too steep for my liking. An RTOS theoretically offers to solve some of the most vexing MCU issues, such as dealing with high latency tasks that can 'lock up' a MCU. This is particularly true with internet related tasks but an SD card can also make the CPU twiddle its thumbs on occasion.

Some MCU's like the Propeller series offer to solve this by allowing you to program multiple cores to work in parallel. So one core can deal with a I/O task, another deals with ADC issues, and so on. Or, you can throw multiple discrete MCUs at the problem (which is what I did). Sure, it's not cost effective in a cost sensitive application, but at low production volumes in a scenario where the hardware cost is not as important, using multiple Teensy's in parallel can be attractive.

Whether or not multiple MCUs are really necessary depends... I happen to like that approach because the the timing in my application is important. For example, my power meter is sampling at 1.4ksps and the current readings and the voltage readings are offset by 2 samples due to the front end I'm using. Start retarding readings, and the resultant measurements will be wrong. So I've set up everything to allow the meter to transmit its findings in the 'idle time' between taking and processing samples.
 
Just getting an RTOS set up correctly to juggle multiple tasks at once is optimistic. Especially if timing is important.
 
A true RTOS "owns" the CPU and hardware and interrupts, etc. So it's not like an optional library for your app. "RTOS", in this context, means something like FreeRTOS (popular freeware) that has its preemptive scheduler enabled. Each task in such an RTOS has its own MCU stack (RAM). Devices that interrupt must have drivers that are RTOS compatible. Etc.
FreeRTOS has a non-preemptive scheduler option (cooperative scheduler). Much simpler because the running task will not be preempted by another task and so mutual exclusion is not needed between tasks.
Most any other true RTOS has at least preemptive scheduling. A novice not aware of RTOS stack-per-task/preemptive scheduler should read, study, and not just dive in uneducated.

Some use the term RTOS for things that aren't either of the above. Beware.

Personally, I never do an overall design that relies upon task preemption. I've done so for 20 years of embedded work on MCUs. But I learned these principles of RTOSes on "minicomputers" (in a rack).
Instead of RTOSes, I've learned to design using finite state machines (FSMs). Very simple code. Very easy to desk-check design and code as correct (verify). A "superloop" calls each FSM in turn. If the FSM has no work to do, based on flags set in ISRs and elapsed time, etc., the FSM just returns. Otherwise the FSM does some brief work and changes its state variable so that next time it's called, it behaves differently.
FSMs are elegantly simple.

So my advice to small MCU users like Teensy and the like, is to avoid RTOSes whenever possible, after an educated decision is made on "do I really need the complexity and the risk-to-reliability of an RTOS?".

There are some cases where an RTOS is prudent, for sure. Usually in quite complex systems and preemption is essential for, e.g., low latency in processing that must be done after an interrupt but is too lengthy to do in the ISR.

Well, okay, yes. I understand a true RTOS basically covers up direct hardware access, and everything must communicate through it.
I am using FreeRTOS (specifically the arduino port of it by Richard Berry), probably should've specified that.
If I'm reading that correctly: You have a loop that checks if there's work to do, and if it does, it does that work. Instead of having a list, though, you had FSMs that all had their own jobs (which sounds like a cluster, but in one machine, to me.). This is essentially what I was originally implementing. Except instead of individual "blocks", I just had a list of numbers that were read off, and sent out as functions. Once their job was done, they were wiped off the list. If they had more work than can be done in one cycle, it would put itself back up onto the list with different arguments to let it know where it left off.
so it was actually 2 lists: one to be done THIS cycle, and one to be done next cycle. There's probably a better way to do it, but that's how I learned it in ASM.
If there was no work to be done, it would end nearly instantly.
However, this had the disadvantage of... I wasn't being reckless? It really had no downside other than I had to code everything with the idea of this overlooking stack that ultimately made most functions have to have a case statement of some sort in them. Also it would take up more memory for anything that needed more than a number 0-255 for its additional information. It was kinda cumbersome to work with, and was producing some awfully long code for straightforward functions (stuff that was supposed to just find 2 x-coords, and given a y-coord draw a line filling down the grid, waiting about 100ms between each y-coord, then again in reverse) were taking about 75 lines - while the version that just locked up the CPU would take 30 lines. Granted, I probably wasn't streamlining it as much as I could've.

Granted: I definitely don't need the power of a full RTOS, seeing how everything that I need to happen "simultaneously" is all my own functions, so I could probably clean up everything that I have, and build my stack system quite a bit cleaner. Probably to the point that I could use it over FreeRTOS, seeing how I likely won't be leveraging the whole power of it. However: it's also something I've never done before (I usually just program without thinking about the OS at all. The OS handles everything silently), and I'd like to try. I 100% started getting into microcontrollers simply because it was something new that I wanted to try.

Sounds very optimistic.

I am a very optimistic person when it comes to my programming projects

Just getting an RTOS set up correctly to juggle multiple tasks at once is optimistic. Especially if timing is important.

Timing isn't SUPER important. just has to be within ~30ms if I were to run it super tight, but honestly, 250 of play will be common. The processor will be waiting a lot.
-which is good, because in my preliminary tests, the arduino FreeRTOS tends to give me about 20ms of drift, which is even within my tight standards.

In relation to your other post:
Long term storage always tends to be the slowest part of any process. It's a shame, but it's what we must live with for now.
Multi-core would be awesome for this, but I would need a minimum of 4 cores, and I would have to have them constantly communicating. Not a good idea for threaded work. Sadly not really a possibility. I probably will end up having a second microcontroller reading inputs, simply because I need a ton of inputs for this. Thinking my knockoff arduino mega would be perfect. So many pins to mess with. and hardware serial. and very cheap.
Tight timing issues like that are always going to be a problem. Back when cpu speeds and instruction times were completely predictable, you could easily pad out extra time. Now speeds fluctuate, and you tend to have an interpreter between you and the CPU, so getting really precise timings is difficult.




I recognise I'm taking on a HUGE learning curve, but it's not anything that needs to be done really any time soon (I'm aiming for early december for the entire project. code'll be made as needed), and that's basically how I program: I throw myself at it until it works, even if I have almost no clue how I'll actually do it. Maybe not the best way (okay, definitely not the best way), but it's the way I like to do it. There's really no risk in a personal project, and in a professional project I wouldn't be so unsure of the exact specs. I would know how everything was going to work and which libraries I would be using before I wrote a line of code. However: this is personal work, so it's a great time to learn new things.

Things I've discovered:
FreeRTOS is an SRAM hog. needed to clean up a lot of memory to get it to run without crashing. which is fine. It'll be running with a lot more SRAM than an UNO when I'm done. The UNO is just great for a quick test. Also one of the biggest SRAM hogs previously was my stack of stuff that needed to be done.
It takes up quite a bit of flash memory (~20% of an arduino uno = ~8,500bytes?), but I wasn't running into any problems with that. Still below 60% total usage
It makes my timings a bit more fuzzy (~10-20ms, perfectly fine for my usage. typically late, sometimes 1-2 early)
It actually needs a bunch of libraries to run properly (not really a problem as long as the compiler is smart enough to strip out unneeded items. I know, I'm a lazy programmer that relies on smart compilers nowadays so I don't have to remember that for(;;) is more efficient than while(1) because the compiler compiles them exactly the same nowadays. again: professional projects I would care. Personal projects I don't.)
It doesn't impact the startup time at all (It gets into my code in the first ms - supposedly. I know millis() can't be trusted too much, but that's the time it gave to me) - although it DOES make the delay longer after that first loop, about 30-40ms -again, still acceptable for me


I know it seems like I'm completely disregarding everybody's advice, but I really am listening to all your criticisms. I understand it'll be difficult, I understand it's COMPLETELY overkill for what I want, I know I'll run into a ton of problems. However: I'm not doing this to make immaculate code. I'm throwing myself into this to learn some new things, do some problem solving, but ultimately to have some fun. Restrictions aren't fun unless they lead to interesting workarounds. As Cave Johnson said: "I'll be honest - we're throwing science at the wall here to see what sticks. No idea what it'll do. Probably nothing." and that is fine by me.
 
Last edited:
Status
Not open for further replies.
Back
Top