Repost: Martin's PPM tester

Arduino projects on the go
Martin
Posts: 766
Joined: 16 Feb 2018, 14:11
Location: Warwickshire

Re: Repost: Martin's PPM tester

Post by Martin »

Well done on getting it working, Al; your version looks great.

I don't have to have the switch in the 'on' position to charge mine, so I must have put the switch in the line on the output side of the voltage booster. The disadvantage of doing it my way is that there's a slight drain on the battery even when it's switched off, because the voltage booster is always boosting the battery voltage - though supplying no current. The drain must be very low though, because I've left my unit in my transmitter case for periods up to about six months without charging, after which it still works. In fact I've never run it flat yet, so maybe it would last a year or more.

I don't think your way of wiring the switch will cause any problems with the Digispark or display: if I ever make another one, I might wire the switch the same way you have - then I'd know there was zero drain on the battery when it's not in use.
User avatar
kalle123
Posts: 35
Joined: 02 Feb 2021, 07:06

Re: Repost: Martin's PPM tester

Post by kalle123 »

Stumbled over your ATTiny code for the ppm tester, Martin.

Just a quick test here using the board manager from https://github.com/SpenceKonde/ATTinyCore

Direct upload with an USBasp adapter without bootloader, still no signal connected, but seems to work ;)

https://imgur.com/s7DAzGp.png

br Karl
ncpiperpilot
Posts: 18
Joined: 13 Jul 2022, 21:05

Re: Repost: Martin's PPM tester

Post by ncpiperpilot »

Going to give a shot at building one of these. Looks like I need a 4 pin 12C interface on the OLED module. The original link for the OLED module is dead. Figured i could find on amazon so i don't have to wait on a slow boat from china. I see some comments discuss different addresses and libraries. Before I order a display, will these work?

DIYmall 1.3" OLED Display Module I2C IIC Serial 128X64 SH1106 LCD Blue Light Screen for Arduino Raspberry Pi 51 MSP420 STIM32 SCR ESP32 https://a.co/d/5xJIKr6

I'm going to plan to use a Diymore pro mini strong board as I have a few.

Thanks,
Newby Bill
User avatar
Phil_G
Posts: 738
Joined: 15 Feb 2018, 23:32
Contact:

Re: Repost: Martin's PPM tester

Post by Phil_G »

Thats the right one Bill :)
ncpiperpilot
Posts: 18
Joined: 13 Jul 2022, 21:05

Re: Repost: Martin's PPM tester

Post by ncpiperpilot »

Phil_G wrote: 07 Sep 2024, 13:23 Thats the right one Bill :)
Thanks for confirming Phil!
Ordered, should have it tomorrow...better than a slow boat but sometimes worth it.
...Bill
bluejets
Posts: 350
Joined: 19 Jun 2019, 04:09

Re: Repost: Martin's PPM tester

Post by bluejets »

Take care with the pinouts as they can be different as you show above.
User avatar
Phil_G
Posts: 738
Joined: 15 Feb 2018, 23:32
Contact:

Re: Repost: Martin's PPM tester

Post by Phil_G »

Anyone using the ATTiny version, remember to load some sort of calibration sketch, tune the OSCCAL and then plug this value into the PPM meter sketch. We've found ATTiny's (Digispark etc) to be accurate and stable once calibrated, but the 'factory' calibration can be way off.
The OSCCAL value can vary widely from chip to chip even in the same batch, usually between 70-120
bluejets
Posts: 350
Joined: 19 Jun 2019, 04:09

Re: Repost: Martin's PPM tester

Post by bluejets »

Phil_G wrote: 08 Sep 2024, 10:20 Anyone using the ATTiny version, remember to load some sort of calibration sketch, tune the OSCCAL and then plug this value into the PPM meter sketch. We've found ATTiny's (Digispark etc) to be accurate and stable once calibrated, but the 'factory' calibration can be way off.
The OSCCAL value can vary widely from chip to chip even in the same batch, usually between 70-120
Any link or how-to...??
User avatar
Phil_G
Posts: 738
Joined: 15 Feb 2018, 23:32
Contact:

Re: Repost: Martin's PPM tester

Post by Phil_G »

Hi jeff, there are many OSCCAL-tuner items on the net, some more complex than others, heres my example:
If you have a scope or frequency meter this code will generate a 10KHz 50:50 square wave on PB4 (physical pin 3 of the ATTiny85).
The idea is to change the value of OSCCAL and re-upload until you get exactly 10KHz on your scope or frequency counter.
I generally start at OSCCAL=100 and adjust in 10's, then 3's then 1's until its spot on, it doesnt take long. A bigger value slows it down.
Once you've found the right value for that chip, you can plug the 'OSCCAL = n' into your project sketch to run on that chip.

Code: Select all

void setup() {
    OSCCAL =  100;              // pick a starting value, adjust to suit
    pinMode(4,OUTPUT);          // output to PB4
    TCNT0 = 0;                  // count up from 0
    TCCR0A = 2 << WGM00;        // set CTC mode
    TCCR0B = 2 << CS00;         // set prescaler to /8 (0.5uS at 16Mhz)
    GTCCR |= 1 << PSR0;         // zero prescaler
    OCR0A = 99;                 // 99 + 1 = 100 x 0.5 uS, at 16MHz (50uS/10KHz)
    TIFR = 1 << OCF0A;          // clear output compare interrupt flag
    TIMSK |= 1 << OCIE0A;       // enable output compare interrupt
}
 
void loop() {}

ISR (TIMER0_COMPA_vect) {
   PORTB ^= 1 << PINB4;        // flip pin PB4
}
 
-or-
Most of my ATTinys are used for 1+1 encoders where the elevator channel is fixed at neutral, so I can I simply check the elevator is 1500 on my PWM meter, or change OSCCAL until it is. Of course after every change you have to recompile & upload but it only takes a few iterations to get it right.

For the DigiSpark encoders I have an edited version of the sketch with channels 'fixed' at neutral, so they can be checked on my PPM meter, and OSCCAL adjusted to give 1500uS, then this value is transferred to the 'actual' encoder sketch to be uploaded to that individual DigiSpark.

So there are many ways to 'tune' OSCCAL and I imagine everyone has their favourite method, I just go for ease & convenience :)
Someone much cleverer than me will probably have a fully automated method, I'm just explaining how I've been doing it all this time.

For less critical projects or if you dont fancy all this faff, the default calibration is probably near enough so comment-out any OSCCAL line with //.

As an aside, personally, in preference to an ATtiny85, for the PPM meter or any timing-related test gear I would always recommend using a Nano or Promini - even a cheap & cheerful one from Aliexpress - with a 16MHz crystal. A crystal is inherently much more accurate and stable than any RC clock - theres no point in having inaccurate test gear :)

I do of course appreciate Martins achievements in working with just an 8-bit timer but a crystal or even a ceramic resonator has to be better than an RC clock, and a 16-bit timer makes it so much easier :)

Cheers
Phil
bluejets
Posts: 350
Joined: 19 Jun 2019, 04:09

Re: Repost: Martin's PPM tester

Post by bluejets »

Thanks.......As I say I looked for examples for this but none turned up on Google search.
As usual I probably used the wrong terms.... 8-)

you can plug the 'OSCCAL = n' into your project sketch to run on that chip......ok...cheers Jeff
Post Reply