Author Topic: ATTiny13A serial output/monitoring  (Read 13841 times)

0 Members and 1 Guest are viewing this topic.

Offline CyberBobTopic starter

  • Contributor
  • Posts: 20
  • Country: gb
ATTiny13A serial output/monitoring
« on: August 03, 2020, 05:39:23 pm »
I do a lot of experimenting with microcontrollers and I'm trying to use an ATTiny13A microcontroller. I want it to collect data and show it in a serial monitor (I do this all the time with other microcontrollers but these connect via USB). I have a FTDI USB to TTL serial adapter as I have seen that some people have used this with the ATTiny13A. I can't seem to get it to work. I use the Arduino IDE to program the microcontrollers and monitor the serial ports. Can anyone help?
 
The following users thanked this post: elenaflorence

Offline sleemanj

  • Super Contributor
  • ***
  • Posts: 3178
  • Country: nz
  • Professional tightwad.
    • The electronics hobby components I sell.
Re: ATTiny13A serial output/monitoring
« Reply #1 on: August 04, 2020, 12:34:30 am »
Use my fork of ATTinyCore and then you can use Serial.whatever as you would normally, to a degree.

You will find some specific ATTiny13 examples in it, after choosing the ATTiny13 from Tools > Board, go to File > Examples > ATTinyCore > Tiny13 > Communication
  Json Url for Board Manager URLs



~~~
EEVBlog Members - get yourself 10% discount off all my electronic components for sale just use the Buy Direct links and use Coupon Code "eevblog" during checkout.  Shipping from New Zealand, international orders welcome :-)
 
The following users thanked this post: elenaflorence, biosetup

Offline sleemanj

  • Super Contributor
  • ***
  • Posts: 3178
  • Country: nz
  • Professional tightwad.
    • The electronics hobby components I sell.
Re: ATTiny13A serial output/monitoring
« Reply #2 on: August 04, 2020, 12:39:50 am »
Also to note that in my core using the Tiny13 the baud rate is locked based on processor speed selected
 
  9.6MHz will be 57600 Baud
  4.8MHz will be 9600 Baud
  1.2MHz will be 9600 Baud

the baud rate given to Serial.begin is ignored.
~~~
EEVBlog Members - get yourself 10% discount off all my electronic components for sale just use the Buy Direct links and use Coupon Code "eevblog" during checkout.  Shipping from New Zealand, international orders welcome :-)
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4675
  • Country: us
Re: ATTiny13A serial output/monitoring
« Reply #3 on: August 05, 2020, 07:55:22 am »
The reason you're having difficulty is that the ATtiny13 doesn't have a UART peripheral, so you have to use some variant of SoftwareSerial.Some of the cores for tiny13 will include that as "Serial" (with various limitations.)  printing ... pretty much anything ... will take up a significant percentage of the Flash and RAM space available.
 

Offline Rick Law

  • Super Contributor
  • ***
  • Posts: 3538
  • Country: us
Re: ATTiny13A serial output/monitoring
« Reply #4 on: August 12, 2020, 06:45:43 pm »
Besides the mere 1K flash, the other constrain is the 64 byte ram.  If you are using something like C to program it, you have to watch your stack carefully.  When you call a function, you really have to trace the nesting (one function calling another function which calls another function...)   64 bytes can be used up very quickly with nested calls.

I first upgraded to a ATTINY25 (2K flash, 128 byte ram), but eventually I went to top of that line: the ATTINY85 (8K flash, 512 byte ram).  That extra resources saved me a lot of time.

The chips are not the same size, but one can bend the ATTINY85's pin just a tiny bit and it fits on the solder pads sized for the ATTINY13.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4675
  • Country: us
Re: ATTiny13A serial output/monitoring
« Reply #5 on: August 13, 2020, 01:43:57 am »
If you're looking at new projects, you should probably look at the new Tiny-0 and Tiny-1 chips like the ATtiny402.  4x the memory of a Tiny13, USART, SPI, and I2C peripherals, and ... cheaper!(alas, no 8k chip to go up against the tiny85, yet.)
 

Offline CyberBobTopic starter

  • Contributor
  • Posts: 20
  • Country: gb
Re: ATTiny13A serial output/monitoring
« Reply #6 on: August 13, 2020, 11:30:24 am »
Thank you all

Sorry for not responding sooner but the notifications of your posts ended up in my Junk folder. I'll work my way through your suggestions and post an update

Thanks again
 

Offline CyberBobTopic starter

  • Contributor
  • Posts: 20
  • Country: gb
Re: ATTiny13A serial output/monitoring
« Reply #7 on: August 13, 2020, 03:44:15 pm »
Hi

I tried the FTDI USB to TTL serial adapter, wired as follows: VCC to VCC, GND to GND, RX to pin 6 and TX to pin 5.

If I removed the TX wire from pin 5 and put the RX pin into pin 5 I got something showing in the serial monitor, though just lots of symbols. I tried connecting the DTR attched to pin 1 but nothing happened. I am using the Arduino serial monitor. I must be missing something (apart from between my ears).

I have the ATTiny 13A set up on a small breadboard attached to an Arduino Uno which acts as an ISP programmer. I have no problems uploading programs to the Tiny. I have another Arduino (well a few, actually) so I tried connecting this to the Tiny after I had uploaded the program (Menu example). I connected VCC to VCC, GND to GND,  RX to pin 6 and TX to pin 5. I opened the Arduino serial monitor and didn't get anything. Is there an easy way of doing it this way (preferred option) and if so, have I got the wiring correct?

Thanks for your help and patience


« Last Edit: August 13, 2020, 04:17:13 pm by CyberBob »
 

Offline Rick Law

  • Super Contributor
  • ***
  • Posts: 3538
  • Country: us
Re: ATTiny13A serial output/monitoring
« Reply #8 on: August 13, 2020, 07:16:08 pm »
At this point, my approach would be: put a scope to the ATTINY's Tx line to see what is coming out.  Keep writing 'U' from the ATTINY, that would send 01010101 out plus a stop bit.  (I am not highly experienced, so there is probably a ton of other better approaches.)

If nothing is coming out from ATTINY's Tx line, that means (a) you are not writing anything to the Tx line correctly, or (b) your chip probably is sick.   If 'U' is coming out, I would try another letter.  I like '3' which should show 00110011, but of course you can choose any other on the ASCII table.  If both 'U' and '3' are coming out, chances are, your software and hardware are transmitting just fine.  The issue would be baud and proper connection.

One confusing thing is, Rx of one connect to Tx of the other.  The  ATTINY's Tx line is what I would expect things you wrote from the ATTINY to come out, and that should got to the Rx of the FTDI.  So make sure you got that correctly.  My FTDI adapter would tolerate a reversed connection at least for a short time - I got them mix up every now and again.  You can always say a prayer, cross your fingers, then swap Rx and Tx and see if you made that mistake.
« Last Edit: August 13, 2020, 07:17:40 pm by Rick Law »
 

Offline sleemanj

  • Super Contributor
  • ***
  • Posts: 3178
  • Country: nz
  • Professional tightwad.
    • The electronics hobby components I sell.
Re: ATTiny13A serial output/monitoring
« Reply #9 on: August 13, 2020, 11:28:40 pm »

If I removed the TX wire from pin 5 and put the RX pin into pin 5 I got something showing in the serial monitor, though just lots of symbols.


Incorrect baud rate or the internal oscillator is too far out of cal (the internal oscillator is very unreliable).

As per my post, if you are using my core the baud is locked to the rates given, ensure you have selected the correct one in your arduino serial terminal.  My core also has a helper example to help you find an OSCCAL value to calibrate the oscillator if necessary.

With serial, RX on one end goes to TX on the other, ie, cross over.

~~~
EEVBlog Members - get yourself 10% discount off all my electronic components for sale just use the Buy Direct links and use Coupon Code "eevblog" during checkout.  Shipping from New Zealand, international orders welcome :-)
 

Offline CyberBobTopic starter

  • Contributor
  • Posts: 20
  • Country: gb
Re: ATTiny13A serial output/monitoring
« Reply #10 on: August 14, 2020, 03:11:08 pm »
Thank you for your responses.

I uploaded the OscillatorCallibration program from the Arduino IDE

These are my setting for the ATTiny 13A
 
  Tools > Board          : ATtiny13
  Tools > BOD            : 2.7V
  Tools > Clock          : 9.6 MHz
  Tools > Timing         : Micros disabled

I left the ATTiny 13A connected to the Arduino ISP and I opened the Arduino serial monitor at 115200 baud rate and started sending "x". After the second "x" sent I got the following
15:53:39.449 -> ⸮⸮⸮

I repeatedly sent "x" for a while and the output continued to be "⸮⸮⸮"

Here is the wiring for my Arduino ISP:

ATtiny13A              Arduino
pin 1          pin 10
pin 5          pin 11
pin 6          pin 12
pin 7          pin 13
pin 8          5v
pin 4                Ground (GND)

I continued to send "x" for at least 5 minutes but didn't get and readable text in the serial monitor.
 

Offline CyberBobTopic starter

  • Contributor
  • Posts: 20
  • Country: gb
Re: ATTiny13A serial output/monitoring
« Reply #11 on: August 14, 2020, 04:11:38 pm »
Connecting the ATTiny (pin6) RX and (pin5) TX to RX and TX respectively on a separate a Arduino Uno. I opened the serial monitor and set a baud rate of 115200. The following kept printing out continually without any interaction from me.
⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮

Eventaully the program stopped sending "⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮" and there was no response when I tried to send "x" (a total of fifty times!).

Swapping the RX and TX connections(ie connecting pin6 of the ATTiny to TX of the Arduino and connecting pin5 to RX of the Arduino, nothing was displayed in the serial monitor. I sent "x" many times without any response.
 

Offline CyberBobTopic starter

  • Contributor
  • Posts: 20
  • Country: gb
Re: ATTiny13A serial output/monitoring
« Reply #12 on: August 16, 2020, 12:43:34 pm »
Can someone please help?

Thanks
 

Offline Rick Law

  • Super Contributor
  • ***
  • Posts: 3538
  • Country: us
Re: ATTiny13A serial output/monitoring
« Reply #13 on: August 16, 2020, 09:57:52 pm »
Can someone please help?

Thanks

You said you had it set to 115200, but sleemanj note that his core locks the Tiny13 baud rate based on clock rate.

Unless you are not using his core, you should try setting your baud on both ends to match the baud that corresponds to your clock rate.

Hope this helps.


Also to note that in my core using the Tiny13 the baud rate is locked based on processor speed selected
 
  9.6MHz will be 57600 Baud
  4.8MHz will be 9600 Baud
  1.2MHz will be 9600 Baud

the baud rate given to Serial.begin is ignored.
 

Offline sleemanj

  • Super Contributor
  • ***
  • Posts: 3178
  • Country: nz
  • Professional tightwad.
    • The electronics hobby components I sell.
Re: ATTiny13A serial output/monitoring
« Reply #14 on: August 16, 2020, 10:44:46 pm »
Going by the options poster is not using my core

115200 on a 9.6Mhz processor is probably pretty iffy, the uart calc https://trolsoft.ru/en/uart-calc suggests it'll be at 4.2% error (assuming an accurate clock)

You should use an alternate baud rate, anything up to 33.6, 56k at a stretch.

(NB: obviously above is for hardware uart which t13 don't have, software uart can only be as good or worse)
« Last Edit: August 16, 2020, 11:32:14 pm by sleemanj »
~~~
EEVBlog Members - get yourself 10% discount off all my electronic components for sale just use the Buy Direct links and use Coupon Code "eevblog" during checkout.  Shipping from New Zealand, international orders welcome :-)
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4675
  • Country: us
Re: ATTiny13A serial output/monitoring
« Reply #15 on: August 16, 2020, 11:58:56 pm »
Quote
software uart can only be as good or worse
Software UARTs can be more accurate than the HW UART, because they can be timed down to the single-clock level, rather than clock/8 or clock/16 for the HW USART.  But only for certain speeds...
 

Offline CyberBobTopic starter

  • Contributor
  • Posts: 20
  • Country: gb
Re: ATTiny13A serial output/monitoring
« Reply #16 on: August 17, 2020, 10:19:39 am »
Thanks again for your responses. I'm new to the terminology here; sleemanj. when you mention your "core", do you mean your wiring https://raw.githubusercontent.com/sleemanj/ArduinoOrientedChipPinoutCreator/master/13.png ?
Is my ISP wired as required as I have successfully uploaded other sketches onto the ATTiny13. Here is the ISP wiring that I use:
ATtiny13A      Arduino
pin 1          pin 10
pin 5          pin 11
pin 6          pin 12
pin 7          pin 13
pin 8          5v
pin 4                Ground (GND)

If this is correct, is my wiring for Serial correct, ie:

ATTiny13A           Arduino
pin 1                    pin 5
pin 6  (RX)            pin 1 (TX)
pin 5 (TX)             pin 0 (RX)

Do I need to disconnect all of the ISP connections whilst monitoring the serial port.

I have tried this at various baud rates with no success. I suppose it all depends on using your "core" which I need clarification on. Is your "core" the wiring or something else (excuse my ignorance).

Thank you all again

Keep safe

Rob
 

Offline sleemanj

  • Super Contributor
  • ***
  • Posts: 3178
  • Country: nz
  • Professional tightwad.
    • The electronics hobby components I sell.
Re: ATTiny13A serial output/monitoring
« Reply #17 on: August 17, 2020, 09:41:30 pm »
~~~
EEVBlog Members - get yourself 10% discount off all my electronic components for sale just use the Buy Direct links and use Coupon Code "eevblog" during checkout.  Shipping from New Zealand, international orders welcome :-)
 

Offline sleemanj

  • Super Contributor
  • ***
  • Posts: 3178
  • Country: nz
  • Professional tightwad.
    • The electronics hobby components I sell.
Re: ATTiny13A serial output/monitoring
« Reply #18 on: August 17, 2020, 11:34:57 pm »
Maybe I think it would be best to spell it out in steps for you

1.  Copy this URL
https://raw.githubusercontent.com/sleemanj/optiboot/master/dists/package_gogo_diy_attiny_index.json
2. Open the Arduino IDE and chooe File > Preferences locate the "Additional Boards Manager URLs" at the bottom of the window
3. Click the window icon next to that field to edit it
4. Paste the URL from 1 into this field on a new line and click OK, and OK to close the preferences
5. Go to Tools > Board > Boards Manager
6. Wait for the update download to finish
7. In "Filter your search" type Tiny13 and choose to install the "DIY ATtiny by James Sleeman"
8. Close the boards manager
9. Choose Tools > Board > DIY ATtiny > ATtiny13
10. Choose Tools > Burn Bootloader to set the fuses correctly if you are not certain they are correct
11. Choose File > Examples > ATTinyCore > Tiny13 > Communication > ASCII Table
12. Upload sketch
13. Disconnect programmer and then connect the serial adapter - RX of the ATTiny connects to TX of your serial adapter, and TX of the ATTiny connects to RX of the adapter
14. Open serial monitor and select 57600 baud







~~~
EEVBlog Members - get yourself 10% discount off all my electronic components for sale just use the Buy Direct links and use Coupon Code "eevblog" during checkout.  Shipping from New Zealand, international orders welcome :-)
 
The following users thanked this post: biosetup

Offline CyberBobTopic starter

  • Contributor
  • Posts: 20
  • Country: gb
Re: ATTiny13A serial output/monitoring
« Reply #19 on: August 18, 2020, 10:43:46 am »
James, your a star!!

I followed your step by step idiots guide and it worked. I think the problems I was having were with the original bootloader. Anyway the ASCII example worked. I noticed that when I tried it again an hour later, nothing showed in the serial monitor (strange). I put a simple program together just to test serial printing and that worked fine:

void setup() {
  // put your setup code here, to run once:
Serial.begin(57600);
}
void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("Hello");
  delay(1000);
}

Now I'll be experimenting with some sensors that I have to see if I can serially print some analog data.

I had a quick look at the examples (File > Examples > ATTinyCore > Tiny13 ) but the links to the wiring didn't work, I got the following error: Invalid upstream response (403)

Most importantly you have ended my three weeks of frustration by solving my serial problem. Hopefully experimenting with analog and digital read and write as well as outputting to the serial monitor won't be as traumatic.

Finally, is the ATTiny13 capable of outputting to an 0.96" i2C OLED ? If I could get that to work it would open up a whole new world of possibilities.

Thank you so much for you patience and help.

Take care and be safe

Rob

 

Offline sleemanj

  • Super Contributor
  • ***
  • Posts: 3178
  • Country: nz
  • Professional tightwad.
    • The electronics hobby components I sell.
Re: ATTiny13A serial output/monitoring
« Reply #20 on: August 18, 2020, 10:37:51 pm »
I'm not aware of any Software I2C library ("Wire" library) that is compact enough to usefully fit in a Tiny13.

Some years ago I did have a crack at getting "SoftWire" to fit and got it to the point it would fit, but it wouldn't have left any space to do anything with it.
~~~
EEVBlog Members - get yourself 10% discount off all my electronic components for sale just use the Buy Direct links and use Coupon Code "eevblog" during checkout.  Shipping from New Zealand, international orders welcome :-)
 
The following users thanked this post: CyberBob

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4675
  • Country: us
Re: ATTiny13A serial output/monitoring
« Reply #21 on: August 19, 2020, 09:03:11 am »
Not to mention that the oled displays are usually bit mapped, and require some sort of font table to display text.  That’s frequently a significant hit even on much bigger chips.  (Many arduino folk with 32k flash find that oled+Ethernet or gps pretty much fills things up!)

 
The following users thanked this post: CyberBob

Offline CyberBobTopic starter

  • Contributor
  • Posts: 20
  • Country: gb
Re: ATTiny13A serial output/monitoring
« Reply #22 on: August 19, 2020, 11:05:51 am »
Yes, as I thought not enough space for a library. Anyway I do have enough to be getting on with now thanks to you both.

Thanks for your patience and help.; it is greatly appreciated

Take care and be safe

Rob
 

Offline newbrain

  • Super Contributor
  • ***
  • Posts: 1920
  • Country: se
Re: ATTiny13A serial output/monitoring
« Reply #23 on: August 19, 2020, 01:55:33 pm »
(Many arduino folk with 32k flash find that oled+Ethernet or gps pretty much fills things up!)
Maybe they should ask for some coding help to Farbrausch, they really can cram a lot in 64k (not a serious comment, sorry).
Nandemo wa shiranai wa yo, shitteru koto dake.
 
The following users thanked this post: CyberBob

Offline CyberBobTopic starter

  • Contributor
  • Posts: 20
  • Country: gb
Re: ATTiny13A serial output/monitoring
« Reply #24 on: August 19, 2020, 03:12:53 pm »
I knew it wouldn't be long.....

I've adapted a couple of the core examples and they work well. I was trying out the "communication" examples and had no problem with the SerialDigital Clock. However, I ran the ASCIITable sketch and it worked first time but when I tried it again, nothing would print to the serial.

With other two examples, ReadASCIIString and MenuDemo, I get the serial output just scrolling through and there is no response to me sending anything to the ATTiny. The hardware and my wiring haven't changed so it is a bit of a mystery to me.

Any pointers would (again) be greatly appreciated

Thanks

Rob
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->