Loading...
  Show Posts
Pages: [1] 2 3 ... 15
1  Using Arduino / Project Guidance / Re: Slotcar speed controller with display and electronic memory project on: May 23, 2013, 02:42:54 pm
Same problem here.......time.
2  Using Arduino / Project Guidance / Re: Slotcar speed controller with display and electronic memory project on: May 14, 2013, 01:49:41 pm
Once again I have to park the project due to no time available.

Paco
3  Using Arduino / Project Guidance / Re: Load sensor amplifier on: March 06, 2013, 06:57:02 am
http://www.ebay.nl/itm/121022291106?ssPageName=STRK:MEWAX:IT&_trksid=p3984.m1423.l2649
24 bit ADC with I2C com for load cell amplification at a low cost ready to use.

Paco
4  Using Arduino / Project Guidance / Re: Charging 3.7v 165mAh LiPo battery on: January 20, 2013, 01:20:35 pm
Have a look at this.
http://www.ebay.nl/itm/3-7V-Lithium-ion-battery-charge-5V-1-5A-USB-out-all-in-one-PCB-charge-iPhone-/121017503840?pt=Battery_Chargers&hash=item1c2d349060

for the price I cant make it myselve.

Paco
5  Using Arduino / Interfacing w/ Software on the Computer / Re: 2 way serial arduino to vb6 on: December 26, 2012, 01:49:13 pm
Here the screenshot of the added code and the serial monitor result.
In serialmonitor I pasted 1,2,3,4,5,6,7:    one time and then once more.
Code:
/*
 * SerialReceiveMultipleFields sketch
 * This code expects a message in the format: 12,345,678,121,16,89,74:
 * This code requires a : character to indicate the end of the data
 */

const int NUMBER_OF_FIELDS = 7; // how many comma separated fields we expect
int fieldIndex = 0;            // the current field being received
int values[NUMBER_OF_FIELDS];   // array holding values for all the fields
int data0= 0;
int data1= 0;
int data2= 0;
int data3= 0;
int data4= 0;
int data5= 0;
int data6= 0;
int i;

void setup()
{
  Serial.begin(9600); // Initialize serial port to send and receive at 9600 baud
}

void loop()
{
  if( Serial.available())
  {
    char ch = Serial.read();
    if(ch >= '0' && ch <= '9') // is this an ascii digit between 0 and 9?
    {
      // yes, accumulate the value
      values[fieldIndex] = (values[fieldIndex] * 10) + (ch - '0');
    }
    else if (ch == ',')  // comma is our separator, so move on to the next field
    {
      if(fieldIndex < NUMBER_OF_FIELDS-1)
        fieldIndex++;   // increment field index
    }
    else
    {
      // any character not a digit or comma ends the acquisition of fields
      // in this example it's the : character sent
      Serial.print( fieldIndex +1);
      Serial.println(" fields received:");
     
      for(int i=0; i<7; i++)
      {
        Serial.print("values[");
        Serial.print(i);
        Serial.print("] = ");
        Serial.print(values[i]);
        Serial.println("]");
      }

      for(int i=0; i<7; i++)
      {
        values[i] = 14;
      }

      for(int i=0; i<7; i++)
      {
        Serial.print("values[");
        Serial.print(i);
        Serial.print("] = ");
        Serial.print(values[i]);
        Serial.println("]");
      }

    }
  }
}
6  Using Arduino / Interfacing w/ Software on the Computer / Re: 2 way serial arduino to vb6 on: December 26, 2012, 11:45:35 am
unfortunenatly
Code:
values[i] = 0; // set the values to zero, ready for the next message
in the for loop did not worked.
Maybe it is against what it should be but what I opted for was the only way I could get it to work.
Other options are welcome anyway.

Paco
7  Using Arduino / Interfacing w/ Software on the Computer / Re: 2 way serial arduino to vb6 on: December 26, 2012, 03:22:54 am
Did cost me some time with debug and try and error.
Used the serialmonitor instead of VB app to find it.

Here is the code for 7 variables that works fine in my case.

Thanks for all assistance.

Paco

Code:
/*
 * SerialReceiveMultipleFields sketch
 * This code expects a message in the format: 12,255,1,121,16,89,74:
 * This code requires a ":" character to indicate the end of the data
*/

const int NUMBER_OF_FIELDS = 7; // how many comma separated fields we expect
int fieldIndex = 0;                        // the current field being received
int values[NUMBER_OF_FIELDS];   // array holding values for all the fields
int data0= 0;
int data1= 0;
int data2= 0;
int data3= 0;
int data4= 0;
int data5= 0;
int data6= 0;
int i;

void setup()
{
  Serial.begin(9600); // Initialize serial port to send and receive at 9600 baud
}

void loop()
{
  if( Serial.available())
  {
    char ch = Serial.read();
    if(ch >= '0' && ch <= '9') // is this an ascii digit between 0 and 9?
    {
      // yes, accumulate the value
      values[fieldIndex] = (values[fieldIndex] * 10) + (ch - '0');
    }
    else if (ch == ',')  // comma is our separator, so move on to the next field
    {
      if(fieldIndex < NUMBER_OF_FIELDS-1)
        fieldIndex++;   // increment field index
    }
    else
    {
      // any character not a digit or comma ends the acquisition of fields
      // in this example it's the : character sent
      Serial.print( fieldIndex +1);
      Serial.println(" fields received:");
      for(int i=0; i <= fieldIndex; i++)

      {
        data0 = (values[0]);
        //Serial.println (data0); //debug line
        data1 = (values[1]);
        //Serial.println (data1); //debug line
        data2 = (values[2]);
        //Serial.println (data2); //debug line
        data3 = (values[3]);
        //Serial.println (data3); //debug line
        data4 = (values[4]);
        //Serial.println (data4); //debug line
        data5 = (values[5]);
        //Serial.println (data5); //debug line
        data6 = (values[6]);
        //Serial.println (data6); //debug line
        values[0] = 0; // set the values to zero, ready for the next message
        values[1] = 0; // set the values to zero, ready for the next message
        values[2] = 0; // set the values to zero, ready for the next message
        values[3] = 0; // set the values to zero, ready for the next message
        values[4] = 0; // set the values to zero, ready for the next message
        values[5] = 0; // set the values to zero, ready for the next message
        values[6] = 0; // set the values to zero, ready for the next message
        fieldIndex = 0;  // ready to start over
      }
    }
  }
}
8  Using Arduino / Project Guidance / Re: Test 1.5v battery mAh with analogread. on: December 23, 2012, 03:22:32 am
http://mad-science.wonderhowto.com/inspiration/diy-arduino-battery-tester-reveals-secret-capacity-disposable-batteries-0134638/

Enjoy
9  Using Arduino / Interfacing w/ Software on the Computer / Re: 2 way serial arduino to vb6 on: December 22, 2012, 12:52:57 pm
Paul,

The current VB code only sends one value to debug and I see I forgot to add this vb code change, my humble appologies for that.
Code:
Private Sub cmdSendDataToController_Click()
strOutput = cmbdeadbandX.Text & "," & ":"
MSComm1.Output = strOutput
End Sub

The receiving code was adapted to receive also one value only.
Code:
const int NUMBER_OF_FIELDS = 1; // how many comma separated fields we expect

When this works I will add the other values at both side one by one.

Will look into it again with your given explanation.

Thanks, Paco
10  Using Arduino / Interfacing w/ Software on the Computer / Re: 2 way serial arduino to vb6 on: December 22, 2012, 11:21:14 am
PaulS, I waited for the Maya calendar to be true but it was not so tried to solve and debug the problem further the past hours.
For AWOL I undressed the large code and removed the LCD code but kept the I2C LCD hooked on the Arduino NANO.
So almost bare code to send and receive from VB app to arduino and vice versa.

1] I power up the Arduino and wait 5 seconds
2] I start the VB app which opens the serial communication automatically at comport 10 once via the USB port and wait 5 seconds
3] VB app has read one variable data with value "12" into the text boxes and when I move the trigger of the controller I see the trigger data live updated in the VB APP. So we have continously updating of the controller data to the VB APP.
4] I set the new setting "8" in the VB APP and press the button send data to controller.
5] I wait 3 seconds and see that the new value "8" is updated in the text box of the VB APP.
6] I move the trigger of the controller I see the trigger data live updated in the VB APP.
So even if we receive and send data once we still have connection.
7] Now I change the data to be send to "14" and once again press the VB app button and send data to the controller.
8] Now the value returned from the Arduino to the VB app text box is "0" where it should be "14".
9] I move the trigger of the controller I see the trigger data live updated in the VB APP. (so the reset problem is temporary switched off)

After restart of the Arduino the same sequence happens. Second click returs "0".
Why does the Arduino by the first click reads the value correctly and second returns 0?
It puzzels me still.

Paco





Code:
const int sensorspeedPin = A0;
byte sensorrawValue = 0;
byte deadbandxValue = 12;
byte i;

const int NUMBER_OF_FIELDS = 1; // how many comma separated fields we expect
int fieldIndex = 0;             // the current field being received
int values[NUMBER_OF_FIELDS];   // array holding values for all the fields

void setup()
{
  Serial.begin(9600);                       // Output to serial writing or BT
}

void loop()
{
 
    Serial.print("A,");
  Serial.println(sensorrawValue);

  Serial.print("K,");
  Serial.println(deadbandxValue);

  sensorrawValue = analogRead(sensorspeedPin); // read the raw value from the linear hall sensor

  if( Serial.available())
  {

    char ch = Serial.read();
    if(ch >= '0' && ch <= '9') // is this an ascii digit between 0 and 9?
    {
      // yes, accumulate the value
      values[fieldIndex] = (values[fieldIndex] * 10) + (ch - '0');
    }
    else if (ch == ',')  // comma is our separator, so move on to the next field
    {
      if(fieldIndex <= NUMBER_OF_FIELDS-1)
        fieldIndex++;   // increment field index
    }
    else
    {
      for(int i=0; i < fieldIndex; i++)
        deadbandxValue = (values[0]);
      {
        values[i] = 0; // set the values to zero, ready for the next message
      }
    }
  }
}
11  Using Arduino / Interfacing w/ Software on the Computer / Re: 2 way serial arduino to vb6 on: December 21, 2012, 11:04:26 am
Paul,

This is the sequence. It is only when the data is send for the second time it reset.
It works fine when I send it only once.

1] I power up the Arduino and wait 5 seconds
2] I start the VB app which opens the serial communication automatically at comport 10 once via the USB port and wait 5 seconds
3] VB app has read the EEPROM data into the text boxes and when I move the trigger of the controller I see the trigger data live updated in the VB APP. So we have continously updating of the controller data to the VB APP.
4] I set the new settings in the VB APP and press the button send data to controller.
5] I wait 3 seconds and see that the new values are updated in the text boxes of the VB APP.
6] I move the trigger of the controller I see the trigger data live updated in the VB APP.
So even if we receive and send data once we still have connection.
7] Now I once again press the VB app button and send data to the controller.
8] Now the Arduino resets or hangs or what ever happens at that point.

It always reset at the 2nd time never at the first.

VB code for sending the data to the controller
Code:
Private Sub cmdSendDataToController_Click()
strOutput = cmbdeadbandX.Text & "," & cmbregBrake.Text & "," & cmbregbrakeState.Text & "," & cmbregHy & "," & cmbspeedBrake.Text & "," & cmbspeedbrakeState.Text & "," & cmbModelNumber.Text & ":"
MSComm1.Output = strOutput
End Sub

vb code that opens the port at formload of the VB app
Code:
Private Sub cmdComport_Click()
On Error Resume Next
With MSComm1
        If .PortOpen Then .PortOpen = False
           .CommPort = cmbComport.Text
           .Settings = "9600,n,8,1"
           .DTREnable = True
           .RTSEnable = True
           .RThreshold = 1
           .SThreshold = 0
           .PortOpen = True
          
  End With
  If MSComm1.PortOpen = False Then
  MsgBox "No USB device available or wrong Com Port number", vbCritical, "Please check!"
  End If

End Sub

12  Using Arduino / Interfacing w/ Software on the Computer / Re: 2 way serial arduino to vb6 on: December 21, 2012, 05:06:10 am
One step further.

Found the cause for the EEPROM values to be restored again.
I connected the display again.
When I press the first time the VB button the data is updated as it should be.
When I click the second time the VB button the Arduino resets and the display is dimmed for a second!
So that is the reason why the EEPROM values are showing up again.
So this means the code for reading from PC to Arduino array is good.
Now remains the question why it can happen that the Arduino resets when we send the same data once again.

Paco
13  Using Arduino / Interfacing w/ Software on the Computer / Re: 2 way serial arduino to vb6 on: December 21, 2012, 04:39:20 am
The reason for commented code lines through out is that I still might use them later or they are SWITCHED off to prevent uncontrolled writing to EEPROM or are part of a base code that need to be used in a later project. This code is 100% test phase and I use one source file which is updated at certain stages and the file number raised. If I make a mistake (happens too often) I can revert back to a previous file. In the end all rubbish and commented code not used will be removed. But I near that stage now.

forgive me I do not understand

Code:
PinMode(2,INPUT);
You gave all those pins nice names - why not use them?


14  Using Arduino / Interfacing w/ Software on the Computer / Re: 2 way serial arduino to vb6 on: December 21, 2012, 04:21:03 am
This project is a learning curve for me.
Along the way new options are dropping in and implemented.
One thing leads to an other and so the code grows and grows. It might be filthy coded and can be reduced in code lines but this is where it stands at the moment with my knowledge.

Paco
15  Using Arduino / Interfacing w/ Software on the Computer / Re: 2 way serial arduino to vb6 on: December 21, 2012, 03:51:51 am
AWOL,

Whole code too large to put it in the response code tags.
Have it zipped.

Thanks for looking in advance.
Curious where I made a mistake.

Paco
Pages: [1] 2 3 ... 15