Go Down

Topic: programming a digisparc pro clone without USB (Read 399 times) previous topic - next topic

Hi,

I', trying to port a kitchen timer sketch from a pro mini to an attiny 167, just to see if it can go bellow the 4mA in sleep mode that I'm getting with the pro mini.
I had to abandon the idea of using an attiny 85 because I'm short of one i/o pin and don't really want to mess with a HVP circuit in order to use the RST pin.
So, I noticed this digstomp (or digisparc, whatever) pro with the attiny167 that got enough pins, I'm failing to program it via usb, and for what I see on the net that's totally normal, not sure if it is a clone thing or what.
So, I'd like to use the tiny Core and program it with Arduino as ISP or USBASP v2 or USB tinyisp v2 but I don't know to what pins to connect the wires.

I've been searching the net for 2 days and found no response, a lot of questions like this one but not even one solution.

thanks in advance...
--
You never learn anything by doing it right.

westfw


6v6gt

I', trying to port a kitchen timer sketch from a pro mini to an attiny 167, just to see if it can go bellow the 4mA in sleep mode that I'm getting with the pro mini.
As an alternative to trying different hardware, why not try to optimize the existing pro-mini. 4mA is far too much in sleep mode. You should get down to a micro amp or so. Some pro-minis have a trace you can cut to disconnect the power led and the regulator (assuming you are powering it at less than 5.5 volts). Also look here for ideas: http://www.gammon.com.au/power

Did you see http://digistump.com/wiki/digispark/tutorials/proisp

Thank you sir, that's exactly what I was looking for.
Even then I was not able to program the attiny167 because avrdude.conf don't know about it.
I had to paste the code from https://github.com/TCWORLD/ATTinyCore/issues/15#issuecomment-39062631 (this is a 2014 post) to the end of avrdude.conf and now I can program it.
The relevant avrdude.conf file is the one at C:\Users\%USERNAME%\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino16\etc\avrdude.conf  (Windows 7).


And I just noticed that the code that I pasted is present in file C:\Users\%USERNAME%\AppData\Local\Arduino15\packages\ATTinyCore\hardware\avr\1.2.5\avrdude_conf.txt but I don't see nothing about that on the docs. Don't get me wrong, I think that Dr. Azzy is a real super-hero, but a small note about this on a easy to find place would be a nice thing.
There looks to be some issues with the pin names vs numbers that I'm still trying to understand. But I have enough to start playing with it.
Thank you.
--
You never learn anything by doing it right.

As an alternative to trying different hardware, why not try to optimize the existing pro-mini. 4mA is far too much in sleep mode. You should get down to a micro amp or so. Some pro-minis have a trace you can cut to disconnect the power led and the regulator (assuming you are powering it at less than 5.5 volts). Also look here for ideas: http://www.gammon.com.au/power
You are right.
I thought that what was eating power was the TM1637 based led display, I turn off the display before going to sleep  with
        display.setBrightness(0, false);
        display.setSegments(alloff);
But to make sure, I just yanked it from the breadboard during and nothing changed, still about 4 mA.
I still can remove the power led and the LDO.
Power is being supplied by 2 AA 2450 mA/h Ni-MH via a boost converter to 5.0V so lowering the voltage is not possible (this boost converter have fixed output).
I tried to divide the clock but it affects the milliseconds ticking, I'm not using delay() only reading the time with millis() I don't know how to solve this.
And this board with the Attiny167 is a bit smaller than the pro mini, this is a good thing,
--
You never learn anything by doing it right.

6v6gt

#5
Aug 26, 2019, 04:28 am Last Edit: Aug 26, 2019, 04:37 am by 6v6gt
You need the boost converter to power the display? It is surely responsible for a good part of  the 4mA quiescent power drain, so regardless of the MCU, you still have to solve that problem. You could power the pro-mini directly from the batteries and switch the boost converter on as required using a pnp transistor or pmosfet configured as a high side switch.
The pro-mini will work down to 1.8 volts (you may have to change the brown out fuse). You can dynamically reduce the clock rate to 4MHz (necessary for 1.8volt operation) by setting F_CPU early in setup() in your sketch together with a matching prescaler value, to ensure the timing functions (millis etc.) still work as expected. Here is an example: https://forum.arduino.cc/index.php?topic=271364.0. That way also, you can still use the installed bootloader.

westfw

Quote
And I just noticed that the code that I pasted is present in file C:\Users\%USERNAME%\AppData\Local\Arduino15\packages\ATTinyCore\hardware\avr\1.2.5\avrdude_conf.txt but I don't see nothing about that on the docs. Don't get me wrong, I think that Dr. Azzy is a real super-hero, but a small note about this on a easy to find place would be a nice thing.
Many cores contain their own version of avrdude.
It should get used automagically when you do "burn bootloader" or "upload using programmer" (and the locations will show up in "verbose" upload output.)  Otherwise, it's likely to be documented about the same as the avrdude in the main Arduino code (ie, "not at all."  :-( )

The funny thing is that burn bootloader works, the error only shows up when using "upload with programmer".
Anyway it's fixed now, thanks.
--
You never learn anything by doing it right.

You need the boost converter to power the display? It is surely responsible for a good part of  the 4mA quiescent power drain,
Probably. I'm using one that looks just like this https://www.ebay.com/itm/362733886809
If it's true that it will work until the input is 0.9V than it will be a good choice.

At first I was planing to use 4xAA with a buck-boost but I can't fit the 4 AA support on the box I'm going to use.
The goal of saving power here is only to don't have to charge the batteries every week, so 4mA is not that bad, but if I could shave 1 or 2 mA only by changing the mcu that would be nice.

I know that the best choice here would be the attiny85.
Whould this circuit be safe to free up the attiny85 RST pin ? - https://github.com/tsaarni/avr-high-voltage-serial-programming
--
You never learn anything by doing it right.

PaulRB

The tiny85 is not going to save much power compared to the ATmega328, so don't be distracted by that idea. Its the rest the circuit you need to fix. At higher currents, boost converters are more efficient than linear regulators, but at very low (sleep) currents, the opposite is true, or can be. This is because boost converters have high quiescent currents compared to linear regulators (most regulators, anyway).

I have several sensor circuits with ATmega328 running at 8MHz/3.3V consuming <50uA in sleep. These are mostly powered by 3xAAA NiMH or 1x 10440 or 18650 size li-ion batteries. I use mcp1700 or 1702 ldo regulators.

I have several sensor circuits with ATmega328 running at 8MHz/3.3V consuming <50uA in sleep. These are mostly powered by 3xAAA NiMH or 1x 10440 or 18650 size li-ion batteries. I use mcp1700 or 1702 ldo regulators.
I still have to test if the led display works at 3.3v.
Even if it does I'd have to switch to a 3 batteries assembly, or a LIPO.
I have some small lipos I could test, but than I'd have to include a protection / charge module, I have a few too... :-)
--
You never learn anything by doing it right.

PaulRB

If your display does not work at 3.3V there are plenty that will. The ssd1306 oleds for example. You could display time in some nice looking font, perhaps even animate the display in some way. They use only ~10mA when displaying text, and ~10uA in sleep mode.

It took me a hell of a lot of head scratching to port my sketch to the digispark pro.
Not a problem with the code, my code is simple, it only counts seconds using millis(), I had problems choosing the pins, I end up only using pins from port A plus PB6 witch as far as I could understand is the pin with the INT0 interrupt.
The "problem" is that it looks that this board wastes more power than the pro micro.
However, as the low power lib that I use in the pro mini does not support the attiny167 i'd like to ask if this is the correct way to put it to sleep.

Code: [Select]

#ifndef TINY
    #include <LowPower.h>
#else
    #include <avr/interrupt.h>
    #include <avr/sleep.h>
#endif

(...)

#ifndef TINY
   attachInterrupt(0, wakeup, LOW);
    LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
    detachInterrupt(0);
#else
    attachInterrupt(0, wakeup, LOW);
    set_sleep_mode(SLEEP_MODE_PWR_DOWN);
    cli();
    sleep_enable();
    sleep_bod_disable();
    sei();
    sleep_cpu();
    sleep_disable();
    detachInterrupt(0);
#endif       


The 1st 3 lines are used in the pro mini and produces a standby current of about 4mA. The rest is used on the digispark pro and produces a standby current of about 10mA.
--
You never learn anything by doing it right.

NB: I'm not ignoring your previous answers, I know that the way to reduce the power waste is primarly on optimizing the power supply.
--
You never learn anything by doing it right.

Go Up