Reading values from adc in dspic33e - microcontroller

Im having some issue trying to consfigure and read ADC's in pic33 from RE* pins. Can anyone give me an example on how to configure and read an adc value from pin RE0 (RP80).

Related

STM32DUINO and analogRead for stm32f103c8t6

I have custom board on which I can upload my code generated from platformio and as board bluepill_f103c8. And I can make led blink etc. but when I want to do analogRead it always returns 0.
I'm trying to read from PA8 pin.
In my setup I put that pin as INPUT_ANALOG, do I need to do something else in order to get the reading?
Voltage that's on pin is about 0.25V that I'm trying to read.
According to STM32F103 Datasheet, page 34, any of 3 onboard ADCs simply do not have the ability to connect to PA8. PA8 can only work as simple GPIO (default, reads only 0 and 1), or as USART1_CK, TIM1_CH1, MCO in alternative configuration.
Arduino can use it as PWM output, or software USART, but there is no way to get analog reading from it.
If you really need to read analog voltage coming to that line, you would have to modify your board and solder PA8 to one of PA0..PA7, PB0..PB1, PC0..PC5 and re-configure ADC to read from that line.
#TonoNam, regarding your problem: unless PA1 is permanently damaged, it is fully capable of working with ADC, so there is something wrong with initialization or reading procedure.
Reference the pinout diagram here https://wiki.stm32duino.com/index.php?title=File:Bluepillpinout.gif
analogRead will only work with the pins which have associated ADC channels.
So this is PA0 through PA7, and then PB0 and PB1, so I guess this is your issue.
Looks like PA8 is a PWM output.

Arduino analogRead function pin 0 not working

I would like to know if someone met the same problem on Arduino board. Know if there is a solution ?
My Arduino board has only 1 month. The pin 0 worked well before. I don't know if it's possible to "burn" a pin. (ex : use a too high voltage ? )
Output A0 connected to 5V Output A1 connected to V
On the screenshots you provided it shows the value on the pin, so technically speaking your analogRead has no problems. Check the link and connections. But regarding your question - yes, you can burn pin and even board with high voltage, so don't forget resistance when it's needed.
Also good practice to use arduino macro for analog pins like analogRead(A0); which is perfectly fine for arduino
Your screenshots show that the values read from A0 are changing (190 first, 300 second). That suggests that the problem lies in the electrical connection. Try to resolder the A0 connector pin, and possibly appropriate pin of the microcontroller. Check if the path leading from the connector to microcontroller pin is not cut somewhere.

BMP180 sensor with BLE112 module

I've been trying to measure temperature and pressure using BMP180 using my BLE112 module from Bluegiga. I connected SDA to pin P1_6 and clock to P1_7 according to the BGScript documentation. Whatever i do i can't get anything pushed to my characteristic... all the time it's equal to 0. I try to proceed as it is mentioned in the BMP180 datasheet.. starting with reading calibration.
This is my hardware.xml: link
temperature_sensor.bgs: link
There is much comments in the code since i am trying to check if i can read anything.. I am using
B-BLE application on android..
If someone could explain me on how to read teamperature or point any mistakes it would be coool!
Thanks!
sorry for late response.
bmp 180 works with serial data(SDA) and SCL(serial clock) which called I2C.
on your microcontroller you are using check the specific pin named SCL and SDA. each MCU have a particular pin dedicated for I2C connection.
also, are you using a library? check whether the library support ur MCU, better still use arduino and adafuit bmp180 library it will be easy to solve your problem.

How to use a DAC on a PWM input generated by timer interrupts?

I'm using a 12-bit Linear LTC2631 DAC, and wish to convert my PWM signal to an analog one via I2C. I am currently not able to come up with an algorithm, and how would the the DAC need to programmed to take in the PWM input and then generate an output. I'm using a Pro Micro 3.3V board.
Any help would be appreciated, including stuff over the internet which I could read up?
Thanks!
If you're going to use an I2C DAC IC like the LTC2631 you don't need PWM at all. You just pass a binary value to the IC via I2C and it will be converted to an analog voltage.
If you want to use PWM to generate an analog signal you might want to filter the output so it doesn't look all square. Take a look at:
http://interface.khm.de/index.php/lab/experiments/arduino-dds-sinewave-generator/
and:
http://www.avdweb.nl/arduino/hardware-interfacing/super-simple-dac.html
Best.
Yes, if you have PWM signals then you don't need to have a DAC at all.just attach a low pass filter after PWM and you will have analog signals.
But if you want to use any I2C DAC you can just provide it binary numbers and it will automatically convert into analog signals.
PWM and DAC both are different method of generating analog signals you don't need to combine it.

read analog value from xbee (non serially)

I'm trying to send an analog value from xbee to another xbee (WHICH IS CONNECTED TO ARDUINO). But I don't want to read this value serially (x=Serial.read();).
I would like to read this value from an arduino's analog input (x=analogRead(A0);). Can I pass an analog value from 1st xbee input pin to 2nd xbee output pin and connect this pin with ex.arduino's analog input (A0) and process it? If it can be done, how does this occur? (sorry for my english)
This is indeed possible. Xbee's have DAC and digital line support. Check out the user manual found in this Manual
The information you're going to need is on page 12. This is for series one xbee's.
For series two xbee's the process is different and can be found in this manual
manual on page 41. Good luck!
I would suspect you would be better off using xbee API and just do an AT command to read pin, then transfer it over serial TX out to the arduino RX in.

Resources