Pages: [1]   Go Down
Author Topic: anyone know sim plot?  (Read 1995 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm just starting to use it.  I'm doing the pentiometer to send a voltage test.  The text screen on the sim plot shows the voltages, but the graph doesn't have a line forming.  I did the plot setup to go from 0-5 v on the y axis, so the data should be in range.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Correction.  There is a line at the bottom, which is the 0 value.  If I expand the minimum y value to -1, I can seethe line moving.  THe problem is that the line stays at a steady 0 v, even though the text box is showing appropriate voltages as I change the petentiometer.
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 221
Posts: 13848
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

can you post a schema how you connected things?
can you post your Arduino code?

If you connect 5V instead of the potentiometer does the graph change?
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It's pretty much the setup for "read analog voltage" where the 5k pot's prongs are connected to 5v, ground, and A0.  I"ve had no problem with it displaying the changing voltage on the text screen of Sim Plot, or the Arduino serial monitor. When I send 5v directly to A0, the text box acknowledges a constant reading of 5v, but the line generated still shows 0. 

 I'm a newbie to arduino, so I looked at the sine wave generator example sketch on the simplot download page, and tinkered around to figure out what code from there I needed to add/alter to combine it into the read analog voltage sample sketch. I'm sure there's something else that I need to change/add in the sketch, but I'm still learning the language.

 My goal is to get it to generate the performance data of some homebrew solar panels that my kids are building.  I've gotten where the arduino logs the solar voltage perfecty, but for now I'm using the petentiometer test to put out a variable voltage until I've figured out how to use the simplot (saves me the trouble of hooking up the panel and voltage divider circuit). Here's the sketch:


void setup()
{ Serial.begin(57600);
   
}

int buffer[20];


void loop()
{

  int data1;

int sensorValue = analogRead(A0);
  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  float voltage = sensorValue * (5.0 / 1023.0);
  // print out the value you read:
  Serial.println(voltage);
 
  //Generating data that will be plotted
  data1 = sensorValue * (5.0 / 1023.0);

  plot(data1);
 
  delay(100); //Need some delay else the program gets swamped with data
 
}

void plot(int data1)
{
  int pktSize;
 
  buffer[0] = 0xCDAB;             //SimPlot packet header. Indicates start of data packet
  buffer[1] = 4*sizeof(int);      //Size of data in bytes. Does not include the header and size fields
 
   
  pktSize = 2 + 2 + (4*sizeof(int)); //Header bytes + size field bytes + data
 
  //IMPORTANT: Change to serial port that is connected to PC
  Serial.write((uint8_t * )buffer, pktSize);
}
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It looks to me like your packet is not set up correctly.
Take a look at the single channel setup: http://www.negtronics.com/simplot/simplot-code-samples/plot-analog-input-data.
Your plot code should look like:
Code:
void plot(int data1)
{
  int pktSize;
 
  buffer[0] = 0xCDAB;             //SimPlot packet header. Indicates start of data packet
  buffer[1] = 1*sizeof(int);      //Size of data in bytes. Does not include the header and size fields
  buffer[2] = data1;
   
  pktSize = 2 + 2 + (1*sizeof(int)); //Header bytes + size field bytes + data
 
  //IMPORTANT: Change to serial port that is connected to PC
  Serial.write((uint8_t * )buffer, pktSize);
}
Logged

Pages: [1]   Go Up
Jump to: