I just tested the ADC on my NucleoNucleoDevelopment and computing boards…o have this dev board for BlueNRG at a pretty hefty price tag though, hopefully the ‘ nucleo ’ & common dev board versions would be out soon Laughing … 007v1.html oops/oh found an…View in hardware catalog ↗STM32F091STM32F091Microcontrollers and processorsSpark Logic archive STM32F091 ADC resolution 10 bit instead of 12 bit GianniDPC Sat Jun 24, 2017 4:04 pm I just tested the ADC on…View in hardware catalog ↗ board, and it shows a 10-bit resolution like the original Arduino’s but my board supports 12-bit. If I look in to the source code, I see that the resolution is also defined as 12-bit.
One more question, I defined the ADC on port A0 in my code, and it works fine when I connect a voltage to A0. But if I plug my wire into A1 for example it also shows me that ADC value even when I didn’t tell my code to do that. Is this normal behaviour?
In had not realised that Frederics core defaulted to AVRAVRMicrocontrollers and processors…Arduino\libraries\U8glib\U8glib.cpp, C:\Program Files (x86)\Arduino\hardware\arduino\ avr \cores\arduino\HardwareSerial.h, C:\Program Files (x86)\Arduino/Blink3.ino, D:\Users\me\A…View in hardware catalog ↗ resolution, I wonder what Daniel’s defaults to.
BTW. Am am not going to change what libmaple does, as plenty of code has been written for it already and expects 12 bit
Sun Jun 25, 2017 9:07 am
[RogerClark – Sat Jun 24, 2017 11:15 pm] – BTW. Am am not going to change what libmaple does, as plenty of code has been written for it already and expects 12 bit
Indeed, it seems a pure Arduino_Core issue, not a libmaple core one.
In had not realised that Frederics core defaulted to AVRAVRMicrocontrollers and processors…Arduino\libraries\U8glib\U8glib.cpp, C:\Program Files (x86)\Arduino\hardware\arduino\ avr \cores\arduino\HardwareSerial.h, C:\Program Files (x86)\Arduino/Blink3.ino, D:\Users\me\A…View in hardware catalog ↗ resolution, I wonder what Daniel’s defaults to.
BTW. Am am not going to change what libmaple does, as plenty of code has been written for it already and expects 12 bit
10 bits. analogReadResolution is the standard Arduino API to change analogread bits from the default 10.
Sun Jun 25, 2017 10:25 am
NOTE: Looking at the API documentation, it seems that changing the resolution using analogReadResolution(X) merely changes the resolution of the result.
A 12 bit read will still be performed, in the case of the STM32FXXX ADCs.
In other words, lowering the resolution will not result in faster analog read calls, and in reality, may make them slower, since the call will also include the time needed to scale the result to the required range.
Sun Jun 25, 2017 12:40 pm
[GianniDPC – Sat Jun 24, 2017 4:31 pm] –
One more question, I defined the ADC on port A0 in my code, and it works fine when I connect a voltage to A0. But if I plug my wire into A1 for example it also shows me that ADC value even when I didn’t tell my code to do that. Is this normal behaviour?
I don’t understand the question. It “shows you the ADC value” what does that mean? Can you post the code you are using?
Sun Jun 25, 2017 12:48 pm
[ahull – Sun Jun 25, 2017 10:25 am] –
NOTE: Looking at the API documentation, it seems that changing the resolution using analogReadResolution(X) merely changes the resolution of the result.
A 12 bit read will still be performed, in the case of the STM32FXXX ADCs.
In other words, lowering the resolution will not result in faster analog read calls, and in reality, may make them slower, since the call will also include the time needed to scale the result to the required range.
The mapping is pretty simple when they are different just a shift. The real overhead is the giant HAL library sitting in front of the ADC combined with the Arduino mentality of lazy pin management, which favors run-time code over compile time code. If you are looking to do optimal ADC sampling at a high rate of speed, then you probably want to move away from Arduino code and implement it with code native to the chip you are using.
Sun Jun 25, 2017 1:26 pm
[Rick Kimball – Sun Jun 25, 2017 12:40 pm] –
[GianniDPC – Sat Jun 24, 2017 4:31 pm] –
One more question, I defined the ADC on port A0 in my code, and it works fine when I connect a voltage to A0. But if I plug my wire into A1 for example it also shows me that ADC value even when I didn’t tell my code to do that. Is this normal behaviour?
I don’t understand the question. It “shows you the ADC value” what does that mean? Can you post the code you are using?
Well the code is the same as in my first post. But what I mean is that I defined A0 as my analog pin in the code and I get my output from the serial monitor as expected, which is 4095 when using a 12-bit resolution.
But when I disconnect the 5V from A0 and connect it to A1 the serial monitor still shows me the same result so 4095. I don’t expect this as I defined A0 as my analog pin in the code and not A1.
Sun Jun 25, 2017 1:35 pm
I’m pretty sure you should be using A0 not 0 and A1 not 1, that is how I have been testing. Otherwise it isn’t going to do the right thing:
[GianniDPC – Sun Jun 25, 2017 1:26 pm] –
But when I disconnect the 5V from A0 and connect it to A1 the serial monitor still shows me the same result so 4095. I don’t expect this as I defined A0 as my analog pin in the code and not A1.
Also, you shouldn’t be connecting 5v to any analog pin. When used as an analog input the max voltage is 3.3v. You are risking frying the analog peripheral.
From the datasheet:
TTa 3.3 V-tolerant I/O directly connected to ADC ..
PA1 is marked TTa
Sun Jun 25, 2017 2:25 pm
[GianniDPC – Sun Jun 25, 2017 1:26 pm] –
[Rick Kimball – Sun Jun 25, 2017 12:40 pm] –
[GianniDPC – Sat Jun 24, 2017 4:31 pm] –
One more question, I defined the ADC on port A0 in my code, and it works fine when I connect a voltage to A0. But if I plug my wire into A1 for example it also shows me that ADC value even when I didn’t tell my code to do that. Is this normal behaviour?
I don’t understand the question. It “shows you the ADC value” what does that mean? Can you post the code you are using?
Well the code is the same as in my first post. But what I mean is that I defined A0 as my analog pin in the code and I get my output from the serial monitor as expected, which is 4095 when using a 12-bit resolution.
But when I disconnect the 5V from A0 and connect it to A1 the serial monitor still shows me the same result so 4095. I don’t expect this as I defined A0 as my analog pin in the code and not A1.
I’m not sure I follow. If you are looking at pin A1, but your input is on pin A0, then if A1 is not tied high or low, it may well drift up towards the level of the adjacent pin(s).
I would get a couple of 100K linear pits, strap them between 5V and gnd, and point the wipers at the A0 and A1 pins, and slowly rotate the wiper from the gnd end towards the 5V end.
You should see the values on the analog pins follow, up till the reach a maximum when the output of the voltage divider formed by the 100k pot hits around 3.3V .. what happens next, if you move the wiper any further, rather depends on how robust the STM32F103STM32F103Microcontrollers and processors…19.html . ag123 Sat Apr 28, 2018 5:54 pm come to think of it blue pill / maple mini ( stm32f103 ) is an *ideal* keyboard controller, the scanning can be done with assistance of sh…View in hardware catalog ↗ pins you have chosen are.
If they are 5V tolerant (remember the STM32F103STM32F103Microcontrollers and processors…19.html . ag123 Sat Apr 28, 2018 5:54 pm come to think of it blue pill / maple mini ( stm32f103 ) is an *ideal* keyboard controller, the scanning can be done with assistance of sh…View in hardware catalog ↗ is a 3.3V device, not a 5V one), then they will stay at the maximum value, and when you rotate the wiper back towards gnd, the value will start to drop again. If they are not 5V tolerant, there will be a lot of heat, perhaps some smoke, and you will earn yourself an honorary membership of our well attended magic smoke club.
Better still, check the spec. of pins in the STM32F103STM32F103Microcontrollers and processors…19.html . ag123 Sat Apr 28, 2018 5:54 pm come to think of it blue pill / maple mini ( stm32f103 ) is an *ideal* keyboard controller, the scanning can be done with assistance of sh…View in hardware catalog ↗ datasheet first to be sure they will suffer such misuse.
EDIT: Thanks Rick, I must admit I was too lazy to check the spec of the analog pins.
Sun Jun 25, 2017 2:28 pm
[ahull – Sun Jun 25, 2017 2:25 pm] –
If they are 5V tolerant (remember the STM32F103STM32F103Microcontrollers and processors…19.html . ag123 Sat Apr 28, 2018 5:54 pm come to think of it blue pill / maple mini ( stm32f103 ) is an *ideal* keyboard controller, the scanning can be done with assistance of sh…View in hardware catalog ↗ is a 3.3V device, not a 5V one), then they will stay at the maximum value, and when you rotate the wiper back towards gnd, the value will start to drop again. If they are not 5V tolerant, there will be a lot of heat, perhaps some smoke, and you will earn yourself an honorary membership of our well attended magic smoke club.
Better still, check the spec. of pins in the STM32F103STM32F103Microcontrollers and processors…19.html . ag123 Sat Apr 28, 2018 5:54 pm come to think of it blue pill / maple mini ( stm32f103 ) is an *ideal* keyboard controller, the scanning can be done with assistance of sh…View in hardware catalog ↗ datasheet first to be sure they will suffer such misuse.
EDIT: Thanks Rick, I must admit I was too lazy to check the spec of the analog pins.
He is using an STM32F091RCSTM32F091RCMicrocontrollers and processors…ck, I must admit I was too lazy to check the spec of the analog pins. He is using an STM32F091RC , the cortex-m0 stuff with the STM Core. ahull Sun Jun 25, 2017 2:38 pm [Rick Kimb…View in hardware catalog ↗, the Cortex-M0Cortex-M0Microcontrollers and processors…accepting a string as a parameter. Thanks @Ivan-Perez * Scheduler: Added support for cortex-M0 . Thanks @PeterVH [core] * Added new PluggableUSB and HID support. This change intro…View in hardware catalog ↗ stuff with the STM Core.
Sun Jun 25, 2017 2:38 pm
[Rick Kimball – Sun Jun 25, 2017 2:28 pm] –
[ahull – Sun Jun 25, 2017 2:25 pm] –
If they are 5V tolerant (remember the STM32F103STM32F103Microcontrollers and processors…19.html . ag123 Sat Apr 28, 2018 5:54 pm come to think of it blue pill / maple mini ( stm32f103 ) is an *ideal* keyboard controller, the scanning can be done with assistance of sh…View in hardware catalog ↗ is a 3.3V device, not a 5V one), then they will stay at the maximum value, and when you rotate the wiper back towards gnd, the value will start to drop again. If they are not 5V tolerant, there will be a lot of heat, perhaps some smoke, and you will earn yourself an honorary membership of our well attended magic smoke club.
Better still, check the spec. of pins in the STM32F103STM32F103Microcontrollers and processors…19.html . ag123 Sat Apr 28, 2018 5:54 pm come to think of it blue pill / maple mini ( stm32f103 ) is an *ideal* keyboard controller, the scanning can be done with assistance of sh…View in hardware catalog ↗ datasheet first to be sure they will suffer such misuse.
EDIT: Thanks Rick, I must admit I was too lazy to check the spec of the analog pins.
He is using an STM32F091RCSTM32F091RCMicrocontrollers and processors…ck, I must admit I was too lazy to check the spec of the analog pins. He is using an STM32F091RC , the cortex-m0 stuff with the STM Core. ahull Sun Jun 25, 2017 2:38 pm [Rick Kimb…View in hardware catalog ↗, the Cortex-M0Cortex-M0Microcontrollers and processors…accepting a string as a parameter. Thanks @Ivan-Perez * Scheduler: Added support for cortex-M0 . Thanks @PeterVH [core] * Added new PluggableUSB and HID support. This change intro…View in hardware catalog ↗ stuff with the STM Core.
In that case, from my brief trawl through the datasheet (Chapter 6 – Electrical Characteristics) I suspect poking the analog pins with 5V is probably a pretty good way to join the magic smoke club.
Sun Jun 25, 2017 2:52 pm
[ahull – Sun Jun 25, 2017 2:38 pm] –
[Rick Kimball – Sun Jun 25, 2017 2:28 pm] –
[ahull – Sun Jun 25, 2017 2:25 pm] –
If they are 5V tolerant (remember the STM32F103STM32F103Microcontrollers and processors…19.html . ag123 Sat Apr 28, 2018 5:54 pm come to think of it blue pill / maple mini ( stm32f103 ) is an *ideal* keyboard controller, the scanning can be done with assistance of sh…View in hardware catalog ↗ is a 3.3V device, not a 5V one), then they will stay at the maximum value, and when you rotate the wiper back towards gnd, the value will start to drop again. If they are not 5V tolerant, there will be a lot of heat, perhaps some smoke, and you will earn yourself an honorary membership of our well attended magic smoke club.
Better still, check the spec. of pins in the STM32F103STM32F103Microcontrollers and processors…19.html . ag123 Sat Apr 28, 2018 5:54 pm come to think of it blue pill / maple mini ( stm32f103 ) is an *ideal* keyboard controller, the scanning can be done with assistance of sh…View in hardware catalog ↗ datasheet first to be sure they will suffer such misuse.
EDIT: Thanks Rick, I must admit I was too lazy to check the spec of the analog pins.
He is using an STM32F091RCSTM32F091RCMicrocontrollers and processors…ck, I must admit I was too lazy to check the spec of the analog pins. He is using an STM32F091RC , the cortex-m0 stuff with the STM Core. ahull Sun Jun 25, 2017 2:38 pm [Rick Kimb…View in hardware catalog ↗, the Cortex-M0Cortex-M0Microcontrollers and processors…accepting a string as a parameter. Thanks @Ivan-Perez * Scheduler: Added support for cortex-M0 . Thanks @PeterVH [core] * Added new PluggableUSB and HID support. This change intro…View in hardware catalog ↗ stuff with the STM Core.
In that case, from my brief trawl through the datasheet (Chapter 6 – Electrical Characteristics) I suspect poking the analog pins with 5V is probably a pretty good way to join the magic smoke club.
Thanks for pointing that out! I’m really stupid doing things before even reading through the data sheet. At least everything still works and I didn’t see any smoke haha.
Sun Jun 25, 2017 3:01 pm
[GianniDPC – Sun Jun 25, 2017 2:52 pm] –
Thanks for pointing that out! I’m really stupid doing things before even reading through the data sheet. At least everything still works and I didn’t see any smoke haha.
That’s what people from the 60’s said about LSD Just wait …
Sun Jun 25, 2017 4:03 pm
Image
What no magic smoke… I’m almost disappointed.
Tue Jun 27, 2017 12:20 pm
wow there’s lot of smoke here
To sum up, STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog ↗ is 3.3V based so provide 5V as input ADC should bring some strange behavior… Mainly for ADC reading.
FYI, on the next release analogRead(0) and analogRead(A0) will be equivalent.
whereas analogWrite(0) is equivalent to analogWrite(D0) .
Tue Jun 27, 2017 12:52 pm
On the subject of magic smoke, I am sure I accidentally powered a F103VET board or several hour from 5V and it survived !
I think on the whole the STM32F103STM32F103Microcontrollers and processors…19.html . ag123 Sat Apr 28, 2018 5:54 pm come to think of it blue pill / maple mini ( stm32f103 ) is an *ideal* keyboard controller, the scanning can be done with assistance of sh…View in hardware catalog ↗ MCU is quite robust
Tue Jun 27, 2017 3:26 pm
roger,
could you please try it with 7.5v / 9v / 12v and report your findings
actually 12v would be redundant as i already know the answer is copious.
stephen