ATtiny85 I really, really, really want to disable reset fuse.

Hi! Please be kind. First post.

Eqmt:. UNO, MEGA1280, Omega MP ISP Programmer, homemade Arduino AVR High-Voltage Serial Programmer shield
Sketches: modified Debounce_Encoder_by_Rafbuff_pde, AVR High-voltage Serial Programmer ino

I want to use an ATtiny85 to decode a rotary encoder AND debounce its pushbutton. Two pins for encoder input, two pins for encoder output ( increment & decrement ) and two pins for push button ( input & output ), all on a 20mm x 15mm pcb. Programming is EASY. Sorry for shouting. There is no end to how to restore the subject fuse advice or going full AVRDUDE and commercial HV programmer.

Can

Serial.println("Writing hfuse");
shiftOut2(DATAOUT, INSTOUT, CLKOUT, MSBFIRST, 0x40, 0x4C);
shiftOut2(DATAOUT, INSTOUT, CLKOUT, MSBFIRST, HFUSE, 0x2C);
shiftOut2(DATAOUT, INSTOUT, CLKOUT, MSBFIRST, 0x00, 0x74);
shiftOut2(DATAOUT, INSTOUT, CLKOUT, MSBFIRST, 0x00, 0x7C);

be rewritten to change the high fuse from 0xDF to 0xFF? Or does the above code push a return to factory default "push button"? Because the value "DF" does not appear, I am wondering if this is machine code to pass instructions rather than passing a value.

Prior supplicants never say how they accidentally disabled the reset function. Can this be done accidentally without erasing the installed program?

Hugh

Won't work. You cant use the SPI interface to change the fuses without the reset pin. The easiest thing to use is this:
http://www.rickety.us/2010/03/arduino-avr-high-voltage-serial-programmer/

There is an alternative and that is to use a bootloader to program the chip, that way you don't have to re-enable the reset pin each time, it simply takes two pins to play the role of a software RX and TX. I have modified Optiboot to work on an Attiny85 amongst others:

One thing to be aware of though is that you must tune the internal oscillator before the bootloader will work. One of the versions of the bootloader (compiled with attiny85_tuned.bat), which is used by default has a built in tuning code that allows the oscillator to be tuned the first time that the bootloader is loaded and will remember the configuration for later. See here for a description of how: ATTinyCore/Readme for Tuned optiboot.txt at master · TCWORLD/ATTinyCore · GitHub

Its not a fool proof method as variations in voltage and temperature can change the oscillator frequency and so the Serial port baud rate goes out of spec. In this case it is possible to still use it if you can find out what the new baud rate is.

You can connect a rotary encoder and two pushbuttons using only two pins of the Tiny85 so long as you don't need to rotate and press a button at the same time (which is awkward to do on the push button of a rotary encoder...)

Use voltage dividers (two resistors) on the rotary encoder outputs so they create pulses at 50% of Vcc as they rotate.

The push buttons connect the pins directly to GND.

Now you use analogRead() to look at the signals.

I've done this before, it works perfectly.

Thank you both. I have been thinking straight digital and trying to keep new skills to read quickly and execute. But I will do anything to make it work as demonstrated by the wiring on my HV programmer shield. If I can find how to's on bootloaders somewhere between "somebody did this for me" and " this is better than what we learned at tech school" I will give it a try and be happier for the extra knowledge.

Fungus, It's good to know that the output of the encoder is stable using a voltage divider. There seems to be so much fear of rotary encoders out there. I agree with you about pushing and turning at the same time. The pushbutton will be used to switch functions of the circuit and until I can afford or build dual rotary encoders, a push button convenient to the other hand will route output of all encoders to respective secondary inputs.

Tom, The code was taken from the first url listed. I have built and tried the arduino-avr-high-voltage-serial-programmer successfully as far as I did not have a bricked ATtiny to start with. I was hoping that a modified sketch could do the reverse and allow I/O on PB5 or change any fuse even if on a one fuse - one change - one sketch basis.

My project is like driving finishing nails with a very small, extemely heavy hammer but the chips are cheap and will prove useful stuck to a bit of pc board with the rotary sensor stuck on the other.

I seem to be going against the flow on this and hope that I do not end up like early engineers that tried to produce a universal digital camera conversion built into the rear access doors of film SLRs. =(

early engineers that tried to produce a universal digital camera conversion built into the rear access doors of film SLRs.

Or that product that was basically a film canister with a "tongue" that was the sensor that laid across the shutter opening like a piece of film. Interesting idea but never got off the ground.


Rob

It is possible to use the reset pin as an analog input without setting the rstdsbl fuse. As long as you never let the voltage get below the reset threshold voltage. The easiest way to have a 10k pullup resistor to VCC and a 47k resistor between the reset pin and your analog signal source. You can even use this method for a pushbutton, though you have to use the ADC to read the state of the button.

Thanks again Tom. Realized that with "blink sketch" and LED on PB5 the low voltage before the first high to LED reset the chip, but never thought to investigate voltage threshold. If the sketch can run fast enough to decode a fast twist of the knob, combining your and fungus' answers, this may give me one rotary encoder, two pushbuttons, four outputs and retain the reset switch in case my immaculate code goes rogue. If not, push button on PS5 voltage divider, rotary encoder on two other inputs, and three pins for outputs gives me what I was asking for and still have the use of a reset switch as a bonus. This is still way, way below potential of an ATtiny. Sorry. Now to investigate the analog side of Arduino and breadboard the circuit.

LowTech:
There seems to be so much fear of rotary encoders out there.

Yep. I don't understand the confusion over rotary encoders (particularly all the efforts to 'debounce' them).

I am coming to agree. Someone trying to use a ten-for-five-dollar encoder a for high rotation application is vastly under engineered. You can add poor quality control and sale of rejects to this and hobbyists will hope the problem does not require a large $100 encoder. Admittedly contact bounce is there but adding a delay after making or breaking contact works for me. Wonder why the tactile switches I've looked at only bounce or arc when released?

I've got a rotary encoder and one push button working using (2) analog inputs. Right now am trying to add the second push button by passing paired input/output pin numbers to the push button processing function. But am tripping over some head slapping detail. Using analog encoder inputs does show more errors at fast rotation, probably needing bit manipulation to replace the slower analogRead function. Good times ahead. Will actually have to look at the datasheet. Figuring out pin terminology was hard enough. The ATtiny is not a TTL technology.

The final project will have around fifteen rotary encoders with dedicated ATtiny85s providing 5 mS up or down pulses to the inputs of the central Arduino board. Am I using hardware or software bounce elimination? Tagging topic solved. Thanks to all.

LowTech:
Someone trying to use a ten-for-five-dollar encoder a for high rotation application is vastly under engineered.

There's no way you should connect one to a motor but they're fine for user input.

LowTech:
Admittedly contact bounce is there but adding a delay after making or breaking contact works for me. Wonder why the tactile switches I've looked at only bounce or arc when released?

There will be bounce but it makes no difference.

All you need to know is that both contacts were closed at some point in time and then both contacts opened again. It doesn't matter how much bounce there was at the moment they were closing or opening because they don't both do it at the same time.

When you've seen a complete both-simultaneously-closed/both-simultaneously-open cycle, that's one click. The direction of rotation is given by whichever contact closed first.

LowTech:
I've got a rotary encoder and one push button working using (2) analog inputs. Right now am trying to add the second push button by passing paired input/output pin numbers to the push button processing function. But am tripping over some head slapping detail. Using analog encoder inputs does show more errors at fast rotation, probably needing bit manipulation to replace the slower analogRead function. Good times ahead. Will actually have to look at the datasheet. Figuring out pin terminology was hard enough. The ATtiny is not a TTL technology.

The Tiny85 ADC can do nearly a million conversions per second if needed but plain "analogRead()" should be fast enough for something being rotated by hand.

It all depends on your software (and your definition of "fast rotation").