Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Shame Boy
Mar 2, 2010

So I left a thing I built running for a while to test it since it's designed to be always on, and it worked flawlessly... for about three days, after which it apparently locked up in some way that prevented the WDT from rebooting it. So it has a bug that only shows up after at least 3 days of continuous uptime, this'll be... fun... to fix :sigh:

Adbot
ADBOT LOVES YOU

kid sinister
Nov 16, 2002

Splode posted:

So the 1961 radar sentry I picked up on ebay arrived. Some of you guys are into vintage stuff right?

There's some sort of yellow (fluoro yellow, not at all orange) crust on the screws, it looks like a metal oxide from the screws corroding. Any idea what kind of metal corrodes like that? I'd like to clean the screws off, but I'd like to know what I'm dealing with first.

I'm a bit wary because this thing ran off mercury batteries, which while not near the screws, is a nice reminder that poo poo from the 60s could be made out of all sorts of weird and wonderful poisons.

At that age, if that thing plugged into the wall, then you'll have to worry about electrocuting yourself through the case if you didn't have the plug flipped over the right way.

As for the yellow crap, my vote is also rust.

Shame Boy
Mar 2, 2010

I've got a question about I2C. My current project has a bunch of different I2C devices dangling off the main board connected by short lengths of wire. With just three connected I've already hit the point where I'm having to turn down the speed to make it work. I want to decrease the pull-up resistance so I can push the speed back up, would it be better to distribute it across all the endpoints (as in, a higher-value resistor pair per device), or just have two lower-value resistors on the main board?

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS
The first option should give you better signal integrity. I just drew out the two options, treating the long run as a transmission line, and the distributed pull up resistors look better, to my eye

CopperHound
Feb 14, 2012

Shame Boy posted:

So I left a thing I built running for a while to test it since it's designed to be always on, and it worked flawlessly... for about three days, after which it apparently locked up in some way that prevented the WDT from rebooting it. So it has a bug that only shows up after at least 3 days of continuous uptime, this'll be... fun... to fix :sigh:
Are you dealing with any variable length strings or arrays? They fragment memory all to hell. Don't know how that would break a WDT though.

I feel your pain with phantom bugs.
I thought I fixed all my problems with adding watchdog timers. I did just have to manually reset a thing that I had going for a month or two which kind of sucks because it is at a remote site and I need a ladder to reach it.

Also I have a dozen or so identical atiny85/rfm69hcw based devices, but two or three of them drain their battery in a few weeks instead of a few months. I can't figure out if the devices aren't reliably going to sleep or if there is some physical defect causing the parasitic drain.

E: oh in regards to the thing that is hard to reach. I do disable the WDT to put it to sleep with an external interrupt. Next time it becomes unresponsive I should check if triggering the interrupt with a jumper brings it back.

CopperHound fucked around with this message at 20:22 on Nov 18, 2019

Shame Boy
Mar 2, 2010

ante posted:

The first option should give you better signal integrity. I just drew out the two options, treating the long run as a transmission line, and the distributed pull up resistors look better, to my eye

Cool, thanks. That's what I was leaning towards but I really didn't have much to go on other than it feeling better.

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS

Shame Boy posted:

So I left a thing I built running for a while to test it since it's designed to be always on, and it worked flawlessly... for about three days, after which it apparently locked up in some way that prevented the WDT from rebooting it. So it has a bug that only shows up after at least 3 days of continuous uptime, this'll be... fun... to fix :sigh:

Also, are you using the heap at all? I had some insidious New-keyword-related issues that would only crop up every half hour of operation on some ESP stuff.

It mostly comes about from software people trying to write embedded Arduino libraries and not understanding the trade offs in embedded development, if that's the problem

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

Shame Boy posted:

So I left a thing I built running for a while to test it since it's designed to be always on, and it worked flawlessly... for about three days, after which it apparently locked up in some way that prevented the WDT from rebooting it. So it has a bug that only shows up after at least 3 days of continuous uptime, this'll be... fun... to fix :sigh:

How are you handling the WDT now? You might want to add logic that requires flags to be set in the foreground and timers before resetting the WDT.

Shame Boy
Mar 2, 2010

CopperHound posted:

Are you dealing with any variable length strings or arrays? They fragment memory all to hell. Don't know how that would break a WDT though.

I feel your pain with phantom bugs.
I thought I fixed all my problems with adding watchdog timers. I did just have to manually reset a thing that I had going for a month or two which kind of sucks because it is at a remote site and I need a ladder to reach it.

Also I have a dozen or so identical atiny85/rfm69hcw based devices, but two or three of them drain their battery in a few weeks instead of a few months. I can't figure out if the devices aren't reliably going to sleep or if there is some physical defect causing the parasitic drain.

I have two theories as to what caused the WDT to fail to trip, and I think the first one is more likely:

1) I was running it in debug mode before the long test run, and when you enable debugging MPLab automatically disables the watchdog timer. It's possible I forgot to re-program it after that, though I thought I did...
2) The way I've implemented it is by calling the WDT reset in FreeRTOS's idle hook, so in theory if something caused all the other tasks to die but for some reason the idle hook kept working it would stay alive I guess?

As for what's causing the actual crash, I have a vague feeling it's some string-heavy code that runs fairly often but as far as I know that's working with fixed-length statically-allocated buffers so hm.

Shame Boy
Mar 2, 2010

ante posted:

Also, are you using the heap at all? I had some insidious New-keyword-related issues that would only crop up every half hour of operation on some ESP stuff.

It mostly comes about from software people trying to write embedded Arduino libraries and not understanding the trade offs in embedded development, if that's the problem

Oh don't worry I've been down that fun path. I do use the heap (as in, FreeRTOS's heap) but very, very carefully. I'm not new'ing anything in loops, stuff is reused rather than deleted, and there's still plenty left over after all my stuff is set up.

taqueso posted:

How are you handling the WDT now? You might want to add logic that requires flags to be set in the foreground and timers before resetting the WDT.

Not a bad idea, right now my handling of it is pretty simple and dumb (idle hook, as mentioned) and could probably use a bit more thought put into it.

asdf32
May 15, 2010

I lust for childrens' deaths. Ask me about how I don't care if my kids die.

Shame Boy posted:

Cool, thanks. That's what I was leaning towards but I really didn't have much to go on other than it feeling better.

At I2C speeds it’s not likely to matter. And it’s not like it’s an impedance matched bus.

BattleMaster
Aug 14, 2000

Shame Boy posted:

I've got a question about I2C. My current project has a bunch of different I2C devices dangling off the main board connected by short lengths of wire. With just three connected I've already hit the point where I'm having to turn down the speed to make it work. I want to decrease the pull-up resistance so I can push the speed back up, would it be better to distribute it across all the endpoints (as in, a higher-value resistor pair per device), or just have two lower-value resistors on the main board?

Consider a different non-resistor pullup scheme altogether, like this "I2C accelerator" by Linear Technology: https://www.analog.com/en/products/ltc1694.html#product-overview (edit: originally by Linear, guess they're owned by Analog Devices now, but the datasheet still has their branding)

I haven't used it myself but it bills itself as being able to keep up with I2C slew rate specs even with high bus capacitance, which is what you'd be dealing with in your situation.

BattleMaster fucked around with this message at 03:44 on Nov 19, 2019

Foxfire_
Nov 8, 2010

Poking the watchdog in an idle task means that if everything else deadlocks, it'll just sit there since idle will still run.

Having no easy good place to put a watchdog poke is one of the downsides of doing a preemptive design. If there are tasks that will always activate regularly, have them set atomic flags and have the idle task poke the watchdog+reset the flags when all the other tasks report activation.

Shame Boy
Mar 2, 2010

BattleMaster posted:

Consider a different non-resistor pullup scheme altogether, like this "I2C accelerator" by Linear Technology: https://www.analog.com/en/products/ltc1694.html#product-overview (edit: originally by Linear, guess they're owned by Analog Devices now, but the datasheet still has their branding)

I haven't used it myself but it bills itself as being able to keep up with I2C slew rate specs even with high bus capacitance, which is what you'd be dealing with in your situation.

Oh hey I had no idea they made stuff like this in a package I could solder, thanks!

Shame Boy
Mar 2, 2010

Foxfire_ posted:

Poking the watchdog in an idle task means that if everything else deadlocks, it'll just sit there since idle will still run.

Having no easy good place to put a watchdog poke is one of the downsides of doing a preemptive design. If there are tasks that will always activate regularly, have them set atomic flags and have the idle task poke the watchdog+reset the flags when all the other tasks report activation.

Yeah so far I've only had the kind of errors that cause FreeRTOS to intentionally hop into a while(1) loop with interrupts disabled and sit there until the watchdog times out, like stack overflows and stuff.

Re: Atomic stuff, I've been a bit confused on how they behave. Do interrupts "build up"/set their respective flags and then fire after you leave the critical section / turn interrupts back on / whatever, or is anything that happens while it's in the critical section just lost forever?

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS
The flag gets set and then only gets unset when the interrupt handler runs. So yeah it builds up.

With the caveat that maybe some architectures I'm not familiar with work differently, and also that I thiiiink the Cortex M4/other Arm systems are kinda weird with their interrupt vectors maybe handling all interrupts and the flag getting cleared for all them? Dunno, not sure on that one

Shame Boy
Mar 2, 2010

ante posted:

The flag gets set and then only gets unset when the interrupt handler runs. So yeah it builds up.

With the caveat that maybe some architectures I'm not familiar with work differently, and also that I thiiiink the Cortex M4/other Arm systems are kinda weird with their interrupt vectors maybe handling all interrupts and the flag getting cleared for all them? Dunno, not sure on that one

Ah ok, that's what I was hoping happened. It's a PIC32MX so nothing too weird I don't think?

e: So wait, it gets set, and then when you re-enable interrupts it immediately fires? Or does it just get set and then nothing happens?

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS
The first one, usually. Never used MIPS though

ante fucked around with this message at 17:52 on Nov 19, 2019

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

The way to find that out precisely is to read the microcontroller manuals (probably multiple 1000 page things) which is daunting but you will always find new info in there.

Shame Boy
Mar 2, 2010

ante posted:

The first one, usually. Never used MIPS though

Ok, thanks.

taqueso posted:

The way to find that out precisely is to read the microcontroller manuals (probably multiple 1000 page things) which is daunting but you will always find new info in there.

With the PIC32 the manual is broken out into a bunch of sub-documents because it's so massive, and I read the one about interrupts a while ago when I was first getting into this project but I think my eyes must have glazed over and slid off the page during the explanation:

http://ww1.microchip.com/downloads/en/devicedoc/61108f.pdf

quote:

All IRQs are sampled on the rising edge of the SYSCLK and latched in associated IFSx registers. A pending IRQ is indicated by the flag bit being equal to ‘1’ in an IFSx register. The pending IRQ will not cause further processing if the corresponding IECx bit in the Interrupt Enable register is clear. The IECx bits act to mask the interrupt flag. If the interrupt is enabled, all IRQs are encoded into a 6 bit wide vector number.

...

The interrupt controller selects the highest priority IRQ among all pending IRQs and presents the associated vector number, priority-level and shadow-set number to the processor core.
The processor core samples the presented vector information between the “E” and “M” stages of the pipeline. If the vector’s priority level presented to the core is greater than the current priority indicated by the CPU Interrupt Priority bits, IPL<2:0> (Status<12:10>), the interrupt is serviced; otherwise, it will remain pending until the current priority is less than the interrupt’s priority.

I'm normally pretty good at deciphering datasheets but stuff about the deep internal workings of microcontrollers always seems to lose me, so let me see if I have it figured out now: there's a register that holds the pending IRQ flag, IFSx, and there's a register that masks it / enables the interrupt, IECx, and if both are set right it gets turned into a 6-bit vector number and the processor reads it and eventually jumps to the vector after doing a bunch of stuff regarding priorities.

Presumably generating that 6-bit vector number from the state of IFS/IEC is an operation that just happens when those conditions are met, not something that has to be "done" by anything that would have been turned off by the interrupts being disabled. So once the interrupts are turned back on, if any of them have their flags set it'll trigger the interrupt normally.

Foxfire_
Nov 8, 2010

For passing back "I ran" information to the idle task like I was talking about, you don't need to disable interrupts.

You can use a load linked+store conditional pair to perform the clears if and only if nothing has touched the target in between. Or there will probably be compiler/library things built on top of those (std::atomic if you've got modern c++)

Each working task sets a flag when it accomplishes something, idle task reads them, pokes the watchdog if all working threads have reported activity, then clears each flag if and only if the corresponding working task didn't rewrite it in the meantime so pathological task scheduling can't break it

Shame Boy
Mar 2, 2010

Foxfire_ posted:

For passing back "I ran" information to the idle task like I was talking about, you don't need to disable interrupts.

You can use a load linked+store conditional pair to perform the clears if and only if nothing has touched the target in between. Or there will probably be compiler/library things built on top of those (std::atomic if you've got modern c++)

Each working task sets a flag when it accomplishes something, idle task reads them, pokes the watchdog if all working threads have reported activity, then clears each flag if and only if the corresponding working task didn't rewrite it in the meantime so pathological task scheduling can't break it

I realized yesterday that I didn't even put the WDT poke in the idle hook, I put it in the tick hook, which is an even more useless place for it to live since ticks are interrupts :v: I moved it to the idle hook and plan to add the flag system y'all are describing since that makes a lot of sense.

I also figured out what the crash was I think, I put in more diagnostics to dump the stack high water mark of all my tasks to the debug serial port and some of the periodic ones were coming very close to an overflow, in fact I think they actually had overflowed at one point while I was watching it and the (admittedly pretty simple) overflow detection FreeRTOS does didn't catch it for whatever reason. Doubled the stack size of the ones that were causing problems and it's been running solidly since, though it's only been on for about a day so I guess we'll see...

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

Mostly an aside: In the tick is a fine place to reset the watchdog if you have the flags verifying the other tasks are running appropriately.

CloFan
Nov 6, 2004

I'm trying to set up a fume extractor using an old server fan. It's actually two fans bolted to gether and has two red, two black, and one each blue white-blue. Giving it 12v makes it scream, and I think that the blue wires can control speed somehow. How do I figure out what component to use as a speed limiter? I guess I could set up a switch and some resistors from the source if I can't figure out what to do with blue.


ante
Apr 9, 2005

SUNSHINE AND RAINBOWS
It's usually a PWM signal. Have an RC servo tester kicking around?

kid sinister
Nov 16, 2002
What do you have for a filter?

sharkytm
Oct 9, 2003

Ba

By

Sharkytm doot doo do doot do doo


Fallen Rib
Why are you running 40mm fans? They'll always be noisy if they're pushing much air due to the swept blade area. Get a 120mm fan and run it on 12v.

You might be able to run those 40s on 9v to quiet them down a bit if you don't want to PWM.

CloFan
Nov 6, 2004

ante posted:

It's usually a PWM signal. Have an RC servo tester kicking around?

Nope

kid sinister posted:

What do you have for a filter?

Nothing, it's for soldering so I don't inhale too much lead

sharkytm posted:

Why are you running 40mm fans? They'll always be noisy if they're pushing much air due to the swept blade area. Get a 120mm fan and run it on 12v.

You might be able to run those 40s on 9v to quiet them down a bit if you don't want to PWM.

Only cause I had it laying around and I figured it would pull plenty of air. You're probably right though, and I think I have some traditional case fans somewhere too that might work better

insta
Jan 28, 2009

ante posted:

It's usually a PWM signal. Have an RC servo tester kicking around?

Wrong PWM signal. These are usually 40khz 0-100% not servo 1000-2000us.

Assuming that's what the blue wire is for, that is...

Shame Boy
Mar 2, 2010

Yeah server fans are designed to move the absolute most air in the smallest form factor, and servers don't care about noise at all, so even if you slow them down they're still pretty loud. Def get a 120mm fan if you want something quieter, it will probably be able to move way more air too since you can run it at full speed without it being too noisy.

CloFan
Nov 6, 2004

Y'all are completely right, I'm going about this the wrong way. I'll find some other fans and set somethign up. Thanks!

Shame Boy
Mar 2, 2010

Anyone know what this kinda connector is?





Socket:



It goes to a mounted LED bar light thing that I bought a while ago and I want to re-mount it somewhere else, but I need a longer run of cable. It carries full 120V line voltage and the other side is a standard 2-prong outlet connector. Since it's wall voltage I'd rather not slice this cable up and solder more wire in there if I don't have to since that would probably void my insurance or something if it ever caught on fire, but I can't seem to figure out what to look for to find another one. I hope it's not proprietary...

KnifeWrench
May 25, 2007

Practical and safe.

Bleak Gremlin

Shame Boy posted:

Anyone know what this kinda connector is?





Socket:



It goes to a mounted LED bar light thing that I bought a while ago and I want to re-mount it somewhere else, but I need a longer run of cable. It carries full 120V line voltage and the other side is a standard 2-prong outlet connector. Since it's wall voltage I'd rather not slice this cable up and solder more wire in there if I don't have to since that would probably void my insurance or something if it ever caught on fire, but I can't seem to figure out what to look for to find another one. I hope it's not proprietary...

Is there a reason you can't use a standard extension cord on the other side? Because what you're describing is exactly as sketchy but way less convenient.

Shame Boy
Mar 2, 2010

KnifeWrench posted:

Is there a reason you can't use a standard extension cord on the other side? Because what you're describing is exactly as sketchy but way less convenient.

I mean I wasn't going to crimp my own cable, I just wanted to buy a new cable that's longer but I have no idea how to search for it.

There's not really that much of a reason not to use an extension cord, except the cable is going to be routed pretty visibly on the wall - it's mounted behind my TV, which is wall-mounted and has all the cables neatly running down in a line using little cable bundle things. Having an extension cord join right in the middle of the otherwise nice, neat cables is kinda ugly.

KnifeWrench
May 25, 2007

Practical and safe.

Bleak Gremlin

Shame Boy posted:

I mean I wasn't going to crimp my own cable, I just wanted to buy a new cable that's longer but I have no idea how to search for it.

There's not really that much of a reason not to use an extension cord, except the cable is going to be routed pretty visibly on the wall - it's mounted behind my TV, which is wall-mounted and has all the cables neatly running down in a line using little cable bundle things. Having an extension cord join right in the middle of the otherwise nice, neat cables is kinda ugly.

Ah, I see. That makes sense. Well, the bad news is, I wouldn't hold out much hope for someone other than the device manufacturer making an extension cable for that specific connector. The terminals themselves might or might not be proprietary, but the specific assembly you're looking for might as well be. The only likely use case for the cable you want is the exact reason you want it, so if the manufacturer doesn't sell it, I would expect that you would need to make something yourself or compromise on aesthetics. Maybe bundle the integral cable so the extension cord plug is behind the TV? Wastes length but avoids the ugly connection.

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

You can splice the cable yourself and use quality heat shrink to make it look decent and safe. A lineman's splice' is strong. But extension cord is the more sane answer.

kid sinister
Nov 16, 2002
Technically, extension cords aren't allowed for permanent use in the NEC.

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS
If you think about it, nothing is permanent

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

It's in place temporarily, until the time when the lamp is moved.


Also, wanted to mention that I agree with KnifeWrench that finding a cable will be likely impossible unless that is some kind of standard connector. And I just thought of a new way to approach this -- replace the connector at the lamp and then get a cord to match


comedy install conduit and an electrical box w/ outlets nearer the lamp option

Adbot
ADBOT LOVES YOU

Shame Boy
Mar 2, 2010

taqueso posted:

You can splice the cable yourself and use quality heat shrink to make it look decent and safe. A lineman's splice' is strong. But extension cord is the more sane answer.

Yeah I mean I 100% trust my ability to safely splice this cable and I've got plenty of good high-quality heatshrink to do it cleanly, I'd just prefer to do something that won't become a thing an insurance company can point to if my house burns down or whatever.


taqueso posted:

It's in place temporarily, until the time when the lamp is moved.


Also, wanted to mention that I agree with KnifeWrench that finding a cable will be likely impossible unless that is some kind of standard connector. And I just thought of a new way to approach this -- replace the connector at the lamp and then get a cord to match


comedy install conduit and an electrical box w/ outlets nearer the lamp option

I was hoping it was some kind of standard connector yeah. I originally bought two on sale and they came with an additional cable to daisy chain one off the other (they have another port at the other end) so it seemed like it might be some kind of standard-ish... thing... but I guess not.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply