Author Topic: making diy electronic dc load (problem with the arduino code)  (Read 1739 times)

0 Members and 1 Guest are viewing this topic.

Offline DzoroTopic starter

  • Contributor
  • Posts: 27
  • Country: mk
Hello guys i have started to build my own electronic dc load which i found on Scullcom Hobby Electronics youtube channel, but some of the components that he used in his design i couldn't get them so i found the closest ones that i can get
so for the DAC i used the same as he did the mcp4725
for the ADC he used mcp3426 i used ADS1115 which is really similar
and for the RTC he used mcp79410 i used ds1307 also pretty close to his
also i build my own circuit board so my components can fit on it
but my problem is in his code because i don't understand coding or any other similar thing. So i did put the libraries for the parts i used but all i get is pages of errors. I cant attach the code bellow because it doesn't support the files but here is a link Scullcom Hobby Electronics link to see the latest version of the code and if anyone can fix it and make it work for my components i would be really grateful
thanks dzoro

The link for the code       http://www.scullcom.com/Electronic_Load_software_V35.ino
 

Offline dobsonr741

  • Frequent Contributor
  • **
  • Posts: 722
  • Country: us
Re: making diy electronic dc load (problem with the arduino code)
« Reply #1 on: April 04, 2023, 01:22:58 am »
Error messages please. Put it in a pdf or paste in the message with the # button.
 

Offline DzoroTopic starter

  • Contributor
  • Posts: 27
  • Country: mk
Re: making diy electronic dc load (problem with the arduino code)
« Reply #2 on: April 04, 2023, 01:46:36 am »
the error messages i think are because of me
because i replaced the include libraries with my parts
and i tought it will work just like that
i have just tried things but i don't know what am i doing so i need someone to change the code for me because i will never be able to change and fix it myself
 

Offline schmitt trigger

  • Super Contributor
  • ***
  • Posts: 2500
  • Country: mx
Re: making diy electronic dc load (problem with the arduino code)
« Reply #3 on: April 04, 2023, 02:30:49 am »
For the DACs, ADCs and RTCs which communication protocol are you using? SPI? I2C? Other?

I know that the DS1307 is I2C, but it only supports low speed. If you are driving the bus at high speed because the other I2C components support it, your DS1307 may hang the bus.

Also, saying that two components are “really similar” is not a good enough description. They may have very similar functionality, but the internal registers may have different addresses, there could be different control registers that may require a setup, and many other subtle technical details which may render them incompatible.

Speaking of I2C addressing: the substitute IC may very likely have a completely different device address than what the library is calling. The device will then proceed to ignore all requests.
« Last Edit: April 04, 2023, 02:51:42 am by schmitt trigger »
 

Offline DzoroTopic starter

  • Contributor
  • Posts: 27
  • Country: mk
Re: making diy electronic dc load (problem with the arduino code)
« Reply #4 on: April 04, 2023, 12:48:37 pm »
The whole circuit uses I2C
For the similarity of the parts i am not entirely sure about the DS1307 but at what i found i think it should work
But for the ADS1115 is very close with MCP3426 they both are 16bit ADC and work with I2C the only thing different is the pinout and number of pins other than that everithing is the same on the board
 

Offline pqass

  • Super Contributor
  • ***
  • Posts: 1024
  • Country: ca
Re: making diy electronic dc load (problem with the arduino code)
« Reply #5 on: April 04, 2023, 03:25:22 pm »
...
for the ADC he used mcp3426 i used ADS1115 which is really similar
and for the RTC he used mcp79410 i used ds1307 also pretty close to his
...
but my problem is in his code because i don't understand coding or any other similar thing.
So i did put the libraries for the parts i used but all i get is pages of errors.
...

You're going to need to do more than just download new libraries for the parts. 
First you must see how the code uses the original parts.

I've pulled the following code that deals with the MCP3426 here:
Code: [Select]
#include <MCP342x.h>                          //Steve Marple library avaiable from    [url]https://github.com/stevemarple/MCP342x[/url]
...
uint8_t address = 0x68;                       //0x68 is the default address for the MCP3426 device
MCP342x adc = MCP342x(address);
...
//---------------------------------------------Read Voltage and Current--------------------------------------------------------------
void readVoltageCurrent (void) {
 
  MCP342x::Config status;
// Initiate a conversion; convertAndRead() will wait until it can be read
  adc.convertAndRead(MCP342x::channel1, MCP342x::oneShot,
           MCP342x::resolution16, MCP342x::gain1,                         //"gain1" means we have select the input amp of the ADC to x1
           1000000, voltage, status);
 
// Initiate a conversion; convertAndRead() will wait until it can be read
  adc.convertAndRead(MCP342x::channel2, MCP342x::oneShot,
           MCP342x::resolution16, MCP342x::gain4,                         //"gain4" means we have select the input amp of the ADC to x4
           1000000, current, status);
 
}

Apart from changing the device address, changes appear localized to just providing a drop-in replacement for the adc.convertAndRead() call.
That is, one-shot read from the correct channel, a 16bit value (into long vars voltage or current), and if necessary time-out after a second. 
The gain in the old library is relative to an internal 2.048V reference, so keep that in mind for the equivalent in the new library.
Luckily, the status variable is just ignored.

Scullcom Load project files (incl. schematic): http://www.scullcom.com/DC_Load_9_2_files.zip
MCP3426 library: https://github.com/stevemarple/MCP342x
MCP3426 datasheet: https://ww1.microchip.com/downloads/en/DeviceDoc/22226a.pdf
ADS1115 tutorial: https://how2electronics.com/how-to-use-ads1115-16-bit-adc-module-with-arduino/
ADS1X15 library: https://github.com/RobTillaart/ADS1X15
ADS1115 datasheet: https://www.ti.com/lit/ds/symlink/ads1115.pdf

New library equivalent is probably something like this:
Code: [Select]
#include "ADS1X15.h"
...
ADS1115 ADS(0x48);
...
void setup() {
...
  ADS.begin();
...
}
...
void readVoltageCurrent (void) {
  ADS.setGain(2);   // for 2.048V max.
  voltage = ADS.readADC(0);   // read channel 1 raw value
  ADS.setGain(8);   // for 0.512V max.     x4 the x1 equivalent
  current = ADS.readADC(1);   // read channel 2 raw value
}


Substituting a DS1307 for the MCP79410 is more involved since the code doesn't appear to use it as a wall-clock.
That is, it keeps resetting the time to zero, and start/stopping like a stop watch.

I've pulled the following code that deals with the MCP79410 here:
Code: [Select]
#include <MCP79410_Timer.h>                   //Scullcom Hobby Electronics library  http://www.scullcom.com/MCP79410Timer-master.zip
...
const byte MCP79410_ADDRESS = 0x6f;           //0x6f is the default address for the MCP79410 Real Time Clock IC
MCP79410_Timer timer = MCP79410_Timer(MCP79410_ADDRESS);
...
various calls to:  timer.reset(), timer.getTime(), timer.getTotalSeconds(), timer.status(), timer.start(), timer.stop()

You could make the equivalent local functions by just using Arduino millis() without any new hardware at all!

MCP79410 library: http://www.scullcom.com/MCP79410Timer-master.zip
MCP79410 datasheet: http://ww1.microchip.com/downloads/en/devicedoc/20002266h.pdf
DS1307 library: https://github.com/adafruit/RTClib
DS1307 datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/DS1307.pdf

Quote
I cant attach the code bellow because it doesn't support the files...

For .ino files, just rename your file to add the suffix .txt and it will upload, or zip it first.

Quote
...but my problem is in his code because i don't understand coding or any other similar thing.

Good luck.
« Last Edit: April 04, 2023, 03:48:26 pm by pqass »
 

Offline DzoroTopic starter

  • Contributor
  • Posts: 27
  • Country: mk
Re: making diy electronic dc load (problem with the arduino code)
« Reply #6 on: April 04, 2023, 07:57:21 pm »
I will try all of the above tthanks alot
I didnt uderstan the thing for the RTC but first i want to mak it work with the ADC
Thanks a lot
 

Offline dobsonr741

  • Frequent Contributor
  • **
  • Posts: 722
  • Country: us
Re: making diy electronic dc load (problem with the arduino code)
« Reply #7 on: April 04, 2023, 09:39:37 pm »
Do you understand/can you code in C? If not this is the first to tackle, so you can fix up code and make it syntactically correct.

Then I would suggest to bring up just the ADC, with the bare minimum code.
 

Offline DzoroTopic starter

  • Contributor
  • Posts: 27
  • Country: mk
Re: making diy electronic dc load (problem with the arduino code)
« Reply #8 on: April 04, 2023, 09:46:28 pm »
I dont know how to code but i really want to make this project work because i have put so much time and effort in the pcb and the enclosure design, i almost went too far with the design but the only thing that is stopping this project is the arduino code
So i will tackle with it search on the internet and try different things
 

Offline DzoroTopic starter

  • Contributor
  • Posts: 27
  • Country: mk
Re: making diy electronic dc load (problem with the arduino code)
« Reply #9 on: April 04, 2023, 09:49:13 pm »
Also one more thing i noticed is that when i put the original code without any changes and try to upload it on the arduino it gives a big error message something to do with the lcd
And when i delete that line it just goes on and on and gives errors on every line that has lcd in it
What could be the problem of that?
 

Offline dobsonr741

  • Frequent Contributor
  • **
  • Posts: 722
  • Country: us
Re: making diy electronic dc load (problem with the arduino code)
« Reply #10 on: April 05, 2023, 01:40:06 am »
You have two choices IMO:
1. Learn to code. Might worth the investment of your time.
2. Ask someone to do the coding for you.
 

Offline DzoroTopic starter

  • Contributor
  • Posts: 27
  • Country: mk
Re: making diy electronic dc load (problem with the arduino code)
« Reply #11 on: April 05, 2023, 01:43:34 am »
I have already tried to learn the code last night i stayed all night long and i only learned some basic stuff about the lcd and the void loop and setup but i didn't understand the things i need to understand to fix it
All in all i have never been a fan of coding so i need to find someone to code it for me
If you can or someone else
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf