Tell us about yourself!

Complete Your Profile
  • Rhasta commented on GreatScottLab's instructable Make Your Own Power Meter/Logger3 months ago
    Make Your Own Power Meter/Logger

    The average is simply the sum of 128 readings, divided by 128. But if you want the average of the last 128 readings, then it's a little different. Two key points: First, you need a buffer size that is a power of 2. So ADC_AVG_BUFFER_SIZE should be 2, 4, 8, 16, 32, 64 etc. Second, the variable type for the tally and buffer should be adapted to your needs. Use uint16_t for the buffer if your sample values are larger than 255 and use a uint32_t for the tally if the sum can be larger than 65535Variables you'll need:#define ADC_AVG_BUFFER_SIZE 128uint8_t ADCAvgBuffer[ADC_AVG_BUFFER_SIZE];uint8_t ADCAvgBufferIndex;uint16_t ADCAvgTally;The code after a read:ADCAvgTally -= ADCAvgBuffer[ADCAvgBufferIndex];ADCAvgTally += NewValue;ADCAvgBuffer[ADCAvgBufferIndex] = NewValue;A...

    see more »

    The average is simply the sum of 128 readings, divided by 128. But if you want the average of the last 128 readings, then it's a little different. Two key points: First, you need a buffer size that is a power of 2. So ADC_AVG_BUFFER_SIZE should be 2, 4, 8, 16, 32, 64 etc. Second, the variable type for the tally and buffer should be adapted to your needs. Use uint16_t for the buffer if your sample values are larger than 255 and use a uint32_t for the tally if the sum can be larger than 65535Variables you'll need:#define ADC_AVG_BUFFER_SIZE 128uint8_t ADCAvgBuffer[ADC_AVG_BUFFER_SIZE];uint8_t ADCAvgBufferIndex;uint16_t ADCAvgTally;The code after a read:ADCAvgTally -= ADCAvgBuffer[ADCAvgBufferIndex];ADCAvgTally += NewValue;ADCAvgBuffer[ADCAvgBufferIndex] = NewValue;ADCAvgBufferIndex++;ADCAvgBufferIndex &= (ADC_AVG_BUFFER_SIZE - 1); // Make sure the index doesn't go above our buffer sizeAverageValue = ADCAvgTally / ADC_AVG_BUFFER_SIZE;One last lesson: The division will be optimized by the compiler into a 'shift.' Dividing by a power of 2 in binary is like dividing by a power of 10 in decimal. To divide 1000 by 10 you simply shift to the right by 1. In binary it is the same. To divide by 128 is simply to shift by 7 positions. That is why this routine is very efficient. It is all very basic operations (add, subtract, increment, shift, etc.) that costs very little CPU time and using a larger buffer only increases the memory used. Using larger variable types will increase CPU time though.Enjoy!

    View Instructable »
  • Rhasta commented on educ8s's instructable Arduino Wireless Weather Station3 months ago
    Arduino Wireless Weather Station

    I can appreciate this is a beginner tutorial, but you will not know how powerful any micro-controller can be until you stop polling and start using interrupts. The nRF can alert you when a new packet has been received, a transmission has failed and so on. The DS3231 also can alert you every 1s, or you can set the Input Capture of the Arduino to alert you every 32768 rising edges coming from the DS3231 Square Wave output.

    View Instructable »
  • Rhasta commented on TheElectroSTUD's instructable PAM8403 6W STEREO AMPLIFIER TUTORIAL7 months ago
    PAM8403 6W STEREO AMPLIFIER TUTORIAL

    I am currently using it at 3.3V and it is doing just fine. The datasheet says it's good for 2.5V to 5.5V with an absolute max of 6V. A 18650 should be good enough.

    View Instructable »
  • Rhasta commented on GreatScottLab's instructable Make Your Own Power Meter/Logger1 year ago
    Make Your Own Power Meter/Logger

    I'm a programmer so when it comes to projects like this, I don't like to simply download libraries and click a few buttons. So I decided to write my own library for my micro-controller family of choice (PIC).The INA219 has only 6 16-bit registers. Four of which are read-only. So it's a pretty simple device. It can be used out-of-the-box like in this video but you lose precision and possibly resolution since it's not calibrated (precision) and you use the whole 3.2A range (as in this case with a 0.1Ohm shunt resistor). So if you never plan to read currents above, say 1A, you lose resolution since the chip can be programmed to handle any range between 0 (I don't know if there's a minimum) and 3.2A. Think of it as your Vref+ for an ADC.So, bottom line, yes it can definitely be done with a ...

    see more »

    I'm a programmer so when it comes to projects like this, I don't like to simply download libraries and click a few buttons. So I decided to write my own library for my micro-controller family of choice (PIC).The INA219 has only 6 16-bit registers. Four of which are read-only. So it's a pretty simple device. It can be used out-of-the-box like in this video but you lose precision and possibly resolution since it's not calibrated (precision) and you use the whole 3.2A range (as in this case with a 0.1Ohm shunt resistor). So if you never plan to read currents above, say 1A, you lose resolution since the chip can be programmed to handle any range between 0 (I don't know if there's a minimum) and 3.2A. Think of it as your Vref+ for an ADC.So, bottom line, yes it can definitely be done with a UNO. The device is just like any I2C devices out there, i.e. NOT tied to Anyduino in any way.

    View Instructable »
  • Rhasta commented on victoryking's instructable DIY Lithium-ion Battery Charger1 year ago
    DIY Lithium-ion Battery Charger

    There are modules like the one here but for multiple cells in series. They are often (always?) labeled as xS where x in the cell number. So for a module that would charge 2 cells in series (7.4V) you'd look for a 2S module. 4 cells? Look for a 4S module.

    Because a circuit like this can be used in more than just a battery charger. Once you know how, you can build stuff with a rechargeable battery that includes the charger. Toys, flashlights, etc. that you just hook up to a USB port to recharge.

    View Instructable »
  • Variable ATX Bench Powersupply - FabLab Edition

    3.3V rail with a 10 Ohms for the dummy load it is then.As it turns out I'm going to need 16V and 24V for some motors so I have decided to use the 2nd 12V rail for a buck/boost converter and skip the LM317 part.Thanks again.

    View Instructable »