RE: Programming ReadPots error

Hello guys, I am new here, and I am having a problem programming this Tig Pulser for my welder.

This is my code.

//Vars

int PWM_DutyCycle=0;
int PWM_DutyCycle_Pin=A0;

int PWM_Period=512;  //period in ms
int PWM_Period_Pin=A1;

//Scale the time of the period or duty by N*1024 milliseconds.
//e.g. PWM_PeriodScale=5 will allow a maximum PWM period of 5120 milliseconds, or ~.195 Hz
int PWM_PeriodScale = 4;
int PWM_DutyScale = 4;

int PWM_Out_Pin = 9;     //31250 base frequency (Timer1)
bool SimpleMode = 1;     //NOTE - Other mode is not implemented!

int ADC1Vals[] = {0,0,0};
int ADC2Vals[] = {0,0,0};

unsigned long HighTime=1;
unsigned long LowTime=0;

void setup() {
//Set up PWM output
pinMode(PWM_Out_Pin, OUTPUT);
}

void loop() {

  ReadPots();
  HighTime = PWM_DutyCycle*PWM_DutyScale;
  LowTime = PWM_Period*PWM_PeriodScale;

  //turn on the out pin
  digitalWrite(PWM_Out_Pin,HIGH);
  delay(HighTime);

  ReadPots();
  HighTime = PWM_DutyCycle*PWM_DutyScale;
  LowTime = PWM_Period*PWM_PeriodScale;

//turn pin off
digitalWrite(PWM_Out_Pin,LOW);
delay(LowTime);
}

Void ReadPots()

The errors I am getting are,

Tig_Pulser:50:1: error: 'Void' does not name a type

 Void ReadPots()

 ^

exit status 1
'ReadPots' was not declared in this scope

Now, if I delete the ReadPots in the loop, and also delete the Void ReadPots, then it uploads to the Mini Pro, but, when I connect to the machine, the pots aren't working at all.

I've also tried changing:

int PWM_DutyCycle=0;
int PWM_DutyCycle_Pin=A0;

int PWM_Period=512;  //period in ms
int PWM_Period_Pin=A1;

to:

int PWM_DutyCycle=0;
int PWM_DutyCycle_Pin=analogRead(A0);

int PWM_Period=512;  //period in ms
int PWM_Period_Pin=analogRead(A1);

I'm new to this, so be patient with me please.

I got this code and the schematic for wiring it up from this person here. YouTube 'This Stuff I Do' Tig Pulser

I also read that A0 pin needs to be disconnected (I read this somewhere) before uploading program. I have already soldered this thing to the board. But I did try unsoldering that one pin, and still same results.

Any help is appreciated.

Thanks in advance, Falcon69

void, not Void.

Please remember to use code tags when posting code.

int PWM_DutyCycle_Pin=analogRead(A0);

Why would a variable with a name implying a pin number contain a reading?

Pin numbers would normally be constants.

I also read that A0 pin needs to be disconnected (I read this somewhere) before uploading program

Where?

sorry, new here, did not know about the code thing.

I'm using 3 potentiometers.

Named them:
PWM_DutyCycle_Pin
PWM_Period_Pin

the other potentiometer is coming off of the 74HC4051 chip into Y1 pin. So it shouldn't have an effect with the arduino code.

What do you mean by 'Pin numbers would normally be constants'

A0 and A1 are the pins of the Pro Mini they are attached to (the wiper of the Pot)

I'm using 3 potentiometers.

Named them:
PWM_DutyCycle_Pin
PWM_Period_Pin

Three items, two names. Bad ratio.

Unless you're planning on changing the values of the pin numbers while the sketch is running, they would normally be constants.

sorry, new here, did not know about the code thing.

You must've missed this

oh, i tried changing the

Void ReadPots()

to

void ReadPots()

I still get that error for that.

But the third Pot isn't even connected to the pins of the Arduino, so I have two pots connected, two names and 2 pins for them. right?

I still get that error for that.

Hint: We can't see your code, unless you show it to us. All of it.
Same goes for the error messages you claim to see.

Here is the code. I manually typed it before, and put it in RED color to see, but now that I know about the code thing, here it is in that format.

//Vars

int PWM_DutyCycle=0;
int PWM_DutyCycle_Pin=A0;

int PWM_Period=512;  //period in ms
int PWM_Period_Pin=A1;

//Scale the time of the period or duty by N*1024 milliseconds.
//e.g. PWM_PeriodScale=5 will allow a maximum PWM period of 5120 milliseconds, or ~.195 Hz
int PWM_PeriodScale = 4;
int PWM_DutyScale = 4;

int PWM_Out_Pin = 9;     //31250 base frequency (Timer1)
bool SimpleMode = 1;     //NOTE - Other mode is not implemented!

int ADC1Vals[] = {0,0,0};
int ADC2Vals[] = {0,0,0};

unsigned long HighTime=1;
unsigned long LowTime=0;

void setup() {
//Set up PWM output
pinMode(PWM_Out_Pin, OUTPUT);
}

void loop() {

  ReadPots();
  HighTime = PWM_DutyCycle*PWM_DutyScale;
  LowTime = PWM_Period*PWM_PeriodScale;

  //turn on the out pin
  digitalWrite(PWM_Out_Pin,HIGH);
  delay(HighTime);

  ReadPots();
  HighTime = PWM_DutyCycle*PWM_DutyScale;
  LowTime = PWM_Period*PWM_PeriodScale;

//turn pin off
digitalWrite(PWM_Out_Pin,LOW);
delay(LowTime);
}

void ReadPots()

Your code is incomplete.

You need to post all the code.

okay, that's all the code I was given. I'm guessing a need a ReadPots.h library or something? Dunno where I get that

You could write it. You've started already.

Or you could ask whoever gave you the code.

his youtube channel has not been updated in over a year. I doubt he's around anymore.

I'm not sure how to go about wrting it. I'm new to this Arduino stuff.

All I've found searchin was how to do pots for an LED, i can't find anything for multiple pots, etc. Technically, I guess that one will work, and the LED can go on PIN 9 (output pin), but, I don't know how to tell the Mini Pro to determine the values between TWO pots.

Reading pots is simple.
Deciding what you do with the readings may be the harder part.

Post a link to where you got the code from. Please use the chain links icon to make the link clickable.

Here it is again

YouTube Tig Pulser Add-On

I see, so you just typed out the code from what's shown on the video:

but the video doesn't show the entire code. Notice how the scroll bar on their screen still has a ways to go before the bottom. It always annoys me when Youtubers do this sort of thing. They also have a bug in their code from an extra closing brace, but it looks like you spotted that and fixed it in your own code.

oh, you are right, after the void ReadPots(), it doesn't show anymore, but scroll bar still can go down.

I'm not sure what to do, or go about this.

I tried rewriting it, but not sure if I have it right.

//Vars
   
int PWM_DutyCycle = 0;          //Variable to store the value from the Potentiometer.
int PWM_DutyCycle_Pin = A0;     //Potentiometer for Main Time (ms)

int PWM_Period = 512;           //Variable to store the value from the Potentiometer in ms
int PWM_Period_Pin = A1;        //Potentiometer for Background Time (ms)

int PWM_PeriodScale = 4;        //Scale the time of the PWM_DutyCycle by N*1024 ms
int PWM_DutyScale = 4;          //Scale the time of the PWM_DutyCycle by N*1024 ms

int PWM_Out_Pin = 9;            //Output Pin to 74HC4051 Pin S0, 31250 base frequency
bool SimpleMode = 1;

int ADC1Vals[] = {0,0,0};
int ADC2Vals[] = {0,0,0};

unsigned long HighTime = 1;
unsigned long LowTime = 0;

void setup() {

//Setup PWM Output
pinMode(PWM_Out_Pin, OUTPUT);
}

void loop() {

PWM_DutyCycle = analogRead(PWM_DutyCyle_Pin);     //Read the value from DutyCycle pin A0
PWM_Period = analogRead(PWM_Period_Pin);          //Read the value from Period pin A1
HighTime = PWM_DutyCycle*PWM_DutyScale;
LowTime = PWM_Period*PWM_PeriodScale;

//Turn on the out pin 9
digitalWrite(PWM_Out_Pin, HIGH);
delay(HighTime);

PWM_DutyCycle = analogRead(PWM_DutyCycle_Pin);    //Read the value from DutyCycle pin A0
PWM_Period = analogRead(PWM_Period_Pin);          //Read the value from Period pin A1
HighTime = PWM_DutyCycle*PWM_DutyScale;
LowTime = PWM_Period*PWM_PeriodScale;

//Turn off the out pin 9
digitalWrite(PWM_Out_Pin, HIGH);
delay(HighTime);

}

it doesn't show errors, but I am unsure if it will work, have not tried

nope, that didn't work either. Pots are still inactive. They are not causing the Tig to pulse, as it should.

Here's a picture of what I'm trying to do.

It seems simple enough, I just don't know how to fix, or fill in the rest of the missing code. I'm new to this code programming stuff. Been on it all day and part of yesterday, and just can't seem to get it.

Any help would be appreciated, thank you guys.

I tried this code now. While Arduino does not give errors now, I am unsure if this is what I needed to do, or if I need to do more.

I don't think I need to add a map line to convert the reading from the 1024 to 255.

//Vars

int PWM_DutyCycle=0;
int PWM_DutyCycle_Pin=A0;

int PWM_Period=512;  //period in ms
int PWM_Period_Pin=A1;

//Scale the time of the period or duty by N*1024 milliseconds.
//e.g. PWM_PeriodScale=5 will allow a maximum PWM period of 5120 milliseconds, or ~.195 Hz
int PWM_PeriodScale = 4;
int PWM_DutyScale = 4;

int PWM_Out_Pin = 9;     //31250 base frequency (Timer1)
bool SimpleMode = 1;     //NOTE - Other mode is not implemented!

int ADC1Vals[] = {0,0,0};
int ADC2Vals[] = {0,0,0};

unsigned long HighTime=1;
unsigned long LowTime=0;

void setup() {
//Set up PWM output
pinMode(PWM_Out_Pin, OUTPUT);
}

void loop() {

 HighTime = PWM_DutyCycle*PWM_DutyScale;
 LowTime = PWM_Period*PWM_PeriodScale;

 //turn on the out pin
 digitalWrite(PWM_Out_Pin,HIGH);
 delay(HighTime);

 ReadPots();
 HighTime = PWM_DutyCycle*PWM_DutyScale;
 LowTime = PWM_Period*PWM_PeriodScale;

//turn pin off
digitalWrite(PWM_Out_Pin,LOW);
delay(LowTime);
}

void ReadPots()
{
 PWM_DutyCycle = analogRead(PWM_DutyCycle_Pin);
 PWM_Period = analogRead(PWM_Period_Pin);
}