SoftModem icon indicating copy to clipboard operation
SoftModem copied to clipboard

Support other microcontrollers than ATmega328p

Open rmeister opened this issue 8 years ago • 9 comments

e.g. ATtiny85, ATmega32u4.

We already began doing some stuff in this direction: publiclab/webjack#17

I managed to get the library sending on the ATtiny with Timer0. The problem with receiving is, that Timer0 uses the same pins as the analog comparator.

A solution could be the ADC multiplexer, which allows to replace AIN1 with an arbitrary ADC input pin. The downside of this solution is, that none of the other ADC pins can be used then, as the ADC has to be disabled. It would be perfect if Timer1 can be used instead of Timer0. But I did not have the time yet to look closely at the differences between the timers.

For the ATmega32u4 the ADC definitively has to be switched off, otherwise it can only use the internal bandgap reference as negative comparator input.

rmeister avatar Aug 16 '16 15:08 rmeister

Would you like to add a transistor? like this http://cyberworks.cocolog-nifty.com/blog/files/modem_mono.pdf

arms22 avatar Aug 18 '16 13:08 arms22

I think I did not understand your question. Will a transistor help in supporting other µCs?

rmeister avatar Aug 18 '16 14:08 rmeister

Yes. An analog comparator becomes unnecessary. There should be an interrupt pin for reception and a general-purpose pin for transmissions.

arms22 avatar Aug 19 '16 00:08 arms22

Ah I see, thanks for the hint. This circuit also has the benefit that it does not need a pin for reference voltage. Would be great to get this working, hope I can build the circuit this week.

Unfortunately there is also a downside: this will break compatibility with existing shields/boards ( I could not find any with transistor built-in). Meaning this probably would require some documentation and a new major release.

rmeister avatar Aug 22 '16 09:08 rmeister

I got SoftModem onto the Leonardo (ATmega32u4), and sending, but not receiving (as noted) using @rmeister's https://github.com/rmeister/SoftModem/tree/attiny-support.

What would it take to get receiving working? I'd like to contribute but am not sure exactly where to start. Thank you!

jywarren avatar Nov 27 '16 21:11 jywarren

I think that additional circuitry is necessary to support SoftModem.

https://github.com/arms22/SoftModem/issues/5#issuecomment-240717423

arms22 avatar Dec 02 '16 05:12 arms22

ATmega32U4 has Analog Comparator.

AIN+ can be connected either to the AIN0 (PE6) pin, or to the internal Bandgap reference. AIN- can only be connected to the ADC multiplexer.

If analogRead is unnecessary, make the following connection. AIN+ AIN0 AIN- AIN1

If you need analogRead, make the following connection. AIN+ AIN0 AIN- Bandgap ref

For more detail see 2.3 Analog Comparator http://www.atmel.com/ja/jp/Images/Atmel-7766-8-bit-AVR-ATmega16U4-32U4_Datasheet.pdf

arms22 avatar Dec 02 '16 06:12 arms22

Thanks! I'm not familiar enough with electronics to help on a circuitry change at this point, but I looked up what an analog comparator is, which was a good first step for me:

http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/step11/How-the-Analog-Comparator-works/

jywarren avatar Dec 05 '16 18:12 jywarren

Just wanted to let you know that I have implemented the circuit shown above http://cyberworks.cocolog-nifty.com/blog/files/modem_mono.pdf and it worked fine on Atmega328. The only exception is that a 100R resistor was replaced by 1K resistor. Analog comparator interrupt handler is replaced by a regular interrupt triggered on RISING.

However SoftModem currently does not work on attiny85, at least on 16Mhz using internal PLL oscillator. Sending kind of works after I replaced timer output with manual port switching and _delay_us(), but with sync errors: sending anything longer than five characters is impossible as the sequence gets corrupted. With default timers it doesn't work at all, even though it sounds like normal. And receiving doesn't work at all, even though the same softmodem works on 328P (with transistor).

gyunaev avatar Jan 30 '17 05:01 gyunaev