Jump to content
 

All Activity

This stream auto-updates     

  1. Earlier
  2. KM1

    Home Offices!

    Like the red-green easy adjust tech
  3. zdenekjs

    Home Offices!

    Rather than spend all my time in my office, I set up one just for work in a different corner of the house. It's helping me with my sanity. To get the monitors the way I wanted it, I had to use a bit of Red-Green Technology and the Handyman's secret weapon. I even put my Headset receiver on a USB extension and got the antenna high up, it really improved the range.
  4. N9WXU

    Home Offices!

    Time to share our home offices. Here is where I am spending my time lately.
  5. I am leaning towards adding a current transformer to the smart switch. Then I have positive feedback that the regulator is also commanding the motor to be on and I can more positively put a time limit on the motor run.
  6. I had a similar choice on the CO2 valve for my fishtank, but if my sw had any glitch the tank would be carbonated like soda and everything would die from the ph drop, so I decided to leave the mechanical regulator in the line for a backup if the electronics fail for some reason. You never know what happens when the power goes out or a battery dies at the wrong time...
  7. A few weeks ago, I installed shop air in my garage. I was pretty proud when it held 150psi all night. But of course I did not quite tighten a connection and at 2 AM (or so my daughter tells me) there was a loud bang followed by a steady "compressor" noise. I did not notice until the next morning when I wondered why there was a noise from the garage. That compressor was pretty hot for running 6 hours straight. Of course this could be stopped by turning the compressor off each night. But, I write embedded software for a living and lately I have been deep into IoT projects. Naturally, this was an ideal chance to do something about my dumb compressor. Ingredients First, I needed a way to switch the compressor on-off remotely. These Sonoff switches are almost perfect. On the plus side, they have an ESP8266 inside so I can run TASOMOTA which is a generic Home Automation / IoT firmware for all things 8266. On the down side, they only are good for 10A. So I added a 120VAC 2 pole relay good for 30A. The compressor has a 16.6A motor draw so some overkill seems appropriate. I refreshed the Sonoff Basic with Tasmota and installed everything inside a metal electrical box. And when I visited the web page: I can turn the compressor on/off from my phone. Fantastic! As long as I had everything opened up, I went ahead and added 2 pressure sensors. Left and right of the primary pressure regulator. The left side sensor goes to the compressor and lets me know what it is doing. I am now tempted to remove the mechanical hysteretic controller on the compressor and simply use the Sonoff switch and some electronic pressure sensing to do the same thing. We shall see. Everything is now in place to ensure the compressor can be automatically turned off, or have a maximum run limit. The only thing left is software! Good Luck.
  8. I am glad to provide some ideas. Let us know what you find. Learning from others is generally cheaper and less painful than learning from my own mistakes.
  9. I think the C libraries can make linear optimization problems much easier to solve in a system. But they are a general purpose solution intended for the general class of optimization problems. There is a good chance that the code you wrote was far simpler and sufficiently optimal for the task at hand due to task specific optimizations. This story is often the case for embedded systems. A general purpose solution is nice and easy but too big/slow for an embedded microcontroller. As the microcontrollers get larger/faster for low costs then these generic or more complete solutions become available. Interestingly this does not always create a "better" performing solution but it often produces a more reliable, faster to market solution by leveraging more widely developed software that has more hours of operation/debugging on it.
  10. Thanks N9WXU. That helps. I know where to look now.
  11. This is great, thanks for summing that up! So if I wanted to calculate the number of bits that are lost from your example above: Source impedance = 100k; LSb Error = 5LSb; log(5)/log(2) = 2.32 This means that the last 2.32 bits are lost and my ENOB = 9.68?
  12. I used to do a fair amount of optimization using linear programming, it was a bit of a pain to code up so I had hoped this would make that easier ...
  13. This tool does three things. Solve the problem helps you learn to think declaratively Helps you develop constraints. To add code to your project, look at the google OR-Tools. In those tools you will provide constraints and data sets. The tools will then do the solving. I would expect some solutions to take quite a bit of CPU time. Currently I am taking basic modeling in discrete optimization in Coursera to learn more about this topic. Training my mind to describe a problem instead of solving it is actually quite hard.
  14. Provided nothing went wrong in your analysis that bit being set means that somewhere something did a software reset, you just have to figure out where this happened. N9WXU gave some possible causes of the RESET instruction being used, but it could really be anywhere. I have even seen this happen with a bad function pointer jumping to a location which contained const data. As a last resort you can search through the program memory for the RESET instruction (you can do this in MPLAB using the memory views) and set a breakpoint at every location containing the reset instruction. That way you should be able to catch it in the debugger and figure out where the reset is coming from.
  15. This is really cool! Can this tool generate C code that I can use in my applications or does it just solve the problem for me?
  16. Glad you found it helpful JG2018, Let me try and answer your questions. This part is just math and the magic of logarithms. The important identity here is that logx(y) = log10(x)/log10(y), and we know that log2(x) will give us how many bits we need to represent x, but our calculators do not do log2 instead they do log10 , which means we have to take log10(x) / log10(2) to get the number of bits we need to represent the number. The short answer is yes because the leakage contributes to a measurement error, and we measure the ADC error as a proportion of LSB size as we described above. How the leakage contributes is a lot more involved and depends on the construction of the ADC and the methods it uses for sampling. Section 7 above shows the simplified circuit diagram of the ADC input path and you can see where Microchip places the leakage current specified in the datasheet. If you calculate the network currents when this circuit is attached to your circuit under measurement you can determine how much of an effect the leakage will have to your measurements. If the source impedance is small the bulk of the current you feed into the pin will end up going into the sampling capacitor and the leakage will have a small effect, but of course the higher your source impedance is the lower the current into the sampling capacitor and the more of an effect the leakage current will have. We can use the PIC18F47K40 example above since the leakage current is indicated in the simplified diagram in section 7 above. If we have 10k of source impedance and we have an additional 1k of internal impedance on the ADC charge path we have at 3V approx 272uA charging the capacitor. The pin leakage is specified at max to be 125nA, which means that 125nA/272uA is the proportion of the charge current lost to our measurement. In this example it contributes 0.0459% error. For a 10-bit ADC this would mean roughly 0.45 LSB of error (calculated as 0.0459% of the full range which is 2^10). That explains the comment in the device datasheet that if your source impedance is more than 10k this will result in an additional error of more than 0.5 LSB which means it will start contributing to your measurement error. To see how this turns into a larger error we can do the same math with a source impedance of 100k instead. This divides the current by 10 and consequently increases the error to 4.59 LSB of error. This means you can still take the measurements but you will potentially have almost 5 LSB of additional error to contend with. And you cannot calibrate out the leakage as it varies with voltage and temperature and the spec already has it varying from 5nA to 125nA depending on these parameters and also the process variation.
  17. Hello, the information in this post is by far one of the best I've seen for ADCs! Thank you for passing this information along to others! I have a few questions I hope you could answer.. 1. How did you get the equation to calculate the fractional number of bits [Log(# LSb error)/Log(2)]? 2. For a high impedance input, does the voltage offset due to leakage current contribute to the LSb error? Thanks!
  18. I am doing some work with combinatorial optimizers. It is amazing what happens when you turn over one more rock and see what scurries out. There is a whole class of programming called declarative programming and I have worked with Haskel enough to be slightly familiar with the concepts. I just learned about flat zinc and an easier environment called MiniZinc which are completely declarative and can be used to solve optimization problems by describing the constraints a valid solution fits inside. So here is a quick example of a program to find the smallest area rectangle where the area is 10 times the circumference. var 1..1000: side1; var 1..1000: side2; var float: area; var float: circumference; constraint area = side1 * side2; constraint circumference = 2 * side1 + 2 * side2; constraint area = 10*circumference; solve minimize area; output ["side1 = \(side1)\nside2 = \(side2)\narea = \(area)\ncircumference = \(circumference)\n"]; and here is the output showing every iteration. side1 = 420 side2 = 21 area = 8820.0 circumference = 882.0 ---------- side1 = 220 side2 = 22 area = 4840.0 circumference = 484.0 ---------- side1 = 120 side2 = 24 area = 2880.0 circumference = 288.0 ---------- side1 = 100 side2 = 25 area = 2500.0 circumference = 250.0 ---------- side1 = 70 side2 = 28 area = 1960.0 circumference = 196.0 ---------- side1 = 60 side2 = 30 area = 1800.0 circumference = 180.0 ---------- side1 = 45 side2 = 36 area = 1620.0 circumference = 162.0 ---------- side1 = 40 side2 = 40 area = 1600.0 circumference = 160.0 ---------- ========== Finished in 82msec Obviously this is a trivial example but it turns out there is quite a bit of research and libraries in this field. For example the google OR-Tools which could be incorporated in your C code. If you need to optimize something and you can describe what the answer looks like (the constraints) then these tools are pretty good. Of course these problems are NP-Complete, so solutions can take some time. Good Luck.
  19. I have not used harmony or web net server so I have not run into this directly. But there may be a few other places to check that cause resets on other systems. Often the assert() functions will end in a software reset, so your code may not call the reset directly, but if you use assert in your error checks you will reset Some malloc libraries will fail with a reset if there is a heap failure.i.e. the stack runs into the heap. This is often detected with a no-mans land between the stack and the heap. The no-mans land is filled with a magic number. If the magic number changed, the stack ran into the no-mans land and may have corrupted the heap.
  20. I'm seeing some random resets with the PIC32MZ1024EFE100 running the Web Net Server project from Harmony 2.06. The RCON register is 0x00000040 which is the SWR (Software Reset Flag) bit. I'm thinking there is a bug in my code but the SYS_RESET_SoftwareReset() function is not being called. What else would cause the SWR bit to be set? Has anyone experienced a simmilar problem? -Devin
  21. Hey, I just noticed that there are some over-clock options. Here is the result when clocked at 960MHz. I could not get it to run at 1GHz. They did warn that cooling was required.
  22. More Data! I just got a Teensy 4 and it is pretty fast. Compiling it in "fastest" and 600Mhz provides the following results. Strangely compiling it in "faster" provides the slightly better results. (6ns) This is pretty fast but I was expecting a bit more performance since it is 6x faster than the Teensy 3.2 tested before. There is undoubtedly a good reason for this performance, and I expect pin toggling to be limited by wait states in writing to the GPIO peripherals. In any case this is still a fast result.
  23. Looks like it gave the segfault upon running? And yes that is what I would expect because on a PC your code is trying to write to memory which should not permit writes. On an embedded system the behavior will depend a lot on the underlying system. Some systems will actually crash in some way, others, like XC8 based PIC microcontrollers, actually copy the read-only section into RAM so the code will actually work. This is why this is so dangerous, the behavior depends on the target and the toolchain and when this is one day tried on another system it could be a real challenge to figure out the mistake because it is so easily masked.
  24. Thanks for pointing out the mistake, we have updated the text accordingly.
  1. Load more activity
 


  • Popular Contributors

    Nobody has received reputation this week.

  • Who's Online (See full list)

    There are no registered users currently online

  • Forum Statistics

    • Total Topics
      73
    • Total Posts
      346
×
×
  • Create New...