openwch / arduino_core_ch32

Core library for CH32duino
230 stars 42 forks source link

request for OPA example #119

Open garudaonekh opened 3 weeks ago

garudaonekh commented 3 weeks ago

Hi, I would like to use CH32V003 OPA(Op-Amps) to connect to PH sensor. But I have no idea how to set this in Arduino.

I found a git which use this this link

Thanks;

maxint-rd commented 3 weeks ago

I had a brief look into that git. From what I saw it appears the author set up his own Arduino-like environment in MounRiver.

The file you're looking for is /User/main.cpp. It contains the familiar setup() and loop() functions. In setup() you can see how ADC is prepared to use OPA and initialize the interrupt handler that calculates the average ADC reading. The loop() function is used to display that average on a TM1637 display.

A first attempt to make an OPA example could be based on that code. Just rename that main.cpp to adc_opa.ino, replace the TM1637 code by Serial.println() and see what else needs to change to get it working.

To make this into a proper example once something is working, all register manipulation should be replaced by calls to functions provided by this core. I don't know to what extend this core already supports OPA and I'm currently not in the position to spend time on this. Hopefully my analysis was helpful to get you started. Good luck!

garudaonekh commented 3 weeks ago

I had a brief look into that git. From what I saw it appears the author set up his own Arduino-like environment in MounRiver.

The file you're looking for is /User/main.cpp. It contains the familiar setup() and loop() functions. In setup() you can see how ADC is prepared to use OPA and initialize the interrupt handler that calculates the average ADC reading. The loop() function is used to display that average on a TM1637 display.

A first attempt to make an OPA example could be based on that code. Just rename that main.cpp to adc_opa.ino, replace the TM1637 code by Serial.println() and see what else needs to change to get it working.

To make this into a proper example once something is working, all register manipulation should be replaced by calls to functions provided by this core. I don't know to what extend this core already supports OPA and I'm currently not in the position to spend time on this. Hopefully my analysis was helpful to get you started. Good luck!

Thanks. Yes, the hardest part is to manipulate the register values. I will try it