Go Down

Topic: 3 Phase sequence indicator (Read 1 time) previous topic - next topic

geoland

Hello guys, newbie here. Just started my project and it's about the subject name . I'm currently waiting for my arduino to arrive so i'm using Proteus to simulate the whole circuit + arduino. I also tried learning some basic arduino stuff ,i think i'm close but i have no results yet. Anyone willing to help??  I posted circuit below .

patduino

Hi geoland,

Although you may think the title and attachments are enough, we'll need more detail.

What exactly are you looking for?  Someone to look over your sketch or someone to write it from scratch?

You'll get more quality responses if you reply with some specifics.

Thanks!
Pat.
There are 10 types of people in the world, those who understand binary, and those that don't.

geoland

#2
Nov 22, 2018, 01:39 am Last Edit: Nov 22, 2018, 01:40 am by geoland
I need someone to look over my scetch and code, I just want a little push so i can do it by myself. I want to know if there are any mistakes in the circuit and if there is a way to check the code i wrote as for now i cannot figure out some things
You can see from images on oscilloscope that Vpeak in A0,A1,A2 is 1,2v ,so knowing that arduino max is 5V =1023, our max is 246
Here is the code:
#include <LiquidCrystal.h>
 const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
 LiquidCrystal lcd(rs, en, d4, d5, d6, d7);



void setup() {  
 pinMode(A0,INPUT);
 pinMode(A1,INPUT);
 pinMode(A2,INPUT);  
                   

 // put your setup code here, to run once:

}

void loop() {
 // put your main code here, to run repeatedly:
double  r=analogRead(A0);
 double y=analogRead(A1);
 double b=analogRead(A2);
 

if (r>130 && r<250)
{
 delay(6.66666);
 if (y>130 && r<250)
 {
   lcd.print("RIGHT");
 }
 if (b>130 && b<=250)
 {
   lcd.print("LEFT");
 }
}
 
 
 

 
}

This is from my first projects in arduino, Hope you Understand :D

Paul_KD7HB

Review "delay()". Takes an integer, not a float.

Paul

patduino

#4
Nov 25, 2018, 02:09 am Last Edit: Nov 25, 2018, 03:54 am by patduino
Good point, but it's not technically wrong because the compiler will cast it, but delay() is in ms, not seconds.  Do you mean 6666 for 6.666 seconds?
There are 10 types of people in the world, those who understand binary, and those that don't.

wvmarle

analogRead() returns an int in range 0-1023, not a double or float.

Change your voltage divider to go a little lower, peaks at about 1V, and use the internal 1.1V reference for better ADC stability.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

geoland

I reduce R1 to 50K so now the vout=12*(R2/(R1+R2)) = 2 volt,in proteus voltmeter i see 1.7 Volt ,the voltage after diode is 0.6 volt and Vpeak= 0.6/0.707=0.84. So if the 5V=1023 then 0.84V =172 , so the values in each analogInput should be 0-->172. I'm ok till here, but something is missing, The lcd doesnt display a value at all

cedarlakeinstruments

After you deal with your LCD issues, remember you need to sample the voltage fast enough to satisfy the Nyquist limit. i.e., if it's a 60Hz waveform, sample at least at 120Hz, preferably faster. The problem is that the LCD display code is probably fairly slow, so you won't be able to sample and update the LCD in one loop fast enough.
Electronics and firmware/software design and assistance. No project too small

patduino

#8
Nov 28, 2018, 04:23 am Last Edit: Nov 28, 2018, 04:25 am by patduino
Quote
The lcd doesnt display a value at all
Have you ever seen the LCD print anything?  If not, then I suggest you start with a simple "Hello World" example sketch to make sure your wiring is correct.

Maybe your detection circuitry is ok now, but the LCD isn't.

Also - what did you ever do with the delay and analogRead statements?  Can you post your new code?

Pat.
There are 10 types of people in the world, those who understand binary, and those that don't.

geoland

#9
Nov 29, 2018, 03:13 am Last Edit: Nov 29, 2018, 03:27 am by geoland
yeah the lcd dislays but not the correct value,sorry for the misunderstanding. for example when i try read a value from a potentiometer in A0 it shows only one value, the circuit remains the same as from the picture ,removed the wires from A0,A1,A2 and installed a potentiometer in A0 ,check the code:

#include <LiquidCrystal.h>
LiquidCrystal lcd (12,11,5,4,3,2);
int pot=A0;
void setup() {
  // put your setup code here, to run once:
 pinMode(pot,INPUT);
 lcd.begin(16,2);

}

void loop() {
  // put your main code here, to run repeatedly:
  int value=analogRead(pot);
  if(value>512)
  {
    lcd.print("Over 2.5");
  }
  if(value<=512)
  {
    lcd.print("under 2.5");
  }
  delay(10000);

}
the lcd displays only Over 2.5, even if the A0 is grounded
thank in advance

wvmarle

Start printing the analogRead() results to the display or the Serial monitor. That shows you what is actually read.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

patduino

You may also want to consider shortening the delay to 1000 during testing.  10 seconds is a long time to wait...
There are 10 types of people in the world, those who understand binary, and those that don't.

cedarlakeinstruments

Try removing this line:
 pinMode(pot,INPUT);

I know that setting the mode to INPUT_PULLUP will definitely cause the problem you're seeing, maybe this will also.
Electronics and firmware/software design and assistance. No project too small

geoland

Try removing this line:
 pinMode(pot,INPUT);

I know that setting the mode to INPUT_PULLUP will definitely cause the problem you're seeing, maybe this will also.
Just remove the line?? Yeah it works now :D I also changed the arduino in proteus :D Thank you guys, i'll post updates

geoland

When i try with the DC source it displays the number correct, but if i connect the A0 to the rectifier it displays always '0'. Check the attachments below

Go Up