Show Posts
Pages: [1]
1  Using Arduino / Installation & Troubleshooting / Re: Error: Unknow device (Code 43) on: May 12, 2013, 07:49:56 pm
Thank you, Erdin.
2  Using Arduino / Installation & Troubleshooting / Error: Unknow device (Code 43) on: May 10, 2013, 09:15:39 pm
Hi all!
I'm using Arduino Nano board, When I plug the board into the computer for the first time, drivers are automatically installed via internet. 
But when using, I have a problem when it's connect to computer:
+ When the windows 7 has finished booting, I plug the USB cable into the computer ---> Board Arduino work normally
+ But before turn on computer, I plug the USB cable. Then turn on computer   --> Windows does not recognize board. (Device Manager: Code 43: Windows has stopped this device because it has reported problems)

Please help me!
Thank in advance!
 
3  Using Arduino / Programming Questions / Re: Input Capture Mode (Timer 1 Atmega 328) on: February 19, 2013, 02:58:44 am
Quote
So it looks like on a logic change.
But as the datasheet:
Quote
When a change of the logic level (an event) occurs on the Input Capture pin (ICP1), alternatively on the Analog Comparator output (ACO), and this change confirms to the setting of the edge detector, a capture will be triggered


4  Using Arduino / Programming Questions / Input Capture Mode (Timer 1 Atmega 328) on: February 18, 2013, 09:49:48 pm
Hi all!
My project, I use Input capture mode to measure the speed of a bicycle (based on the switching frequency of the switch).I use library FreqMeasure (reference http://www.pjrc.com/teensy/td_libs_FreqMeasure.html).
My problem: I do not really understand vector interrupt TIMER1_CAPT_vect. When this interrupt occurs? It looks like it interrupt when there is a change levels logic, so the set ICES1 (0-falling edge or 1-rising edge) to the setting of the edge detector has no effect.
In my case:

When the switch is OFF, D8 pin is HIGH. Switch is ON, D8 pin is LOW.
As I understand, when I set ICES1 = 0 (falling edge detector), interrupt TIMER1_CAPT_vect only happened one time when the switch status from OFF to ON (HIGH to LOW logic).But in fact it is not true.
P/s: I really do not understand FreqMeasure library. If anyone has good speed measurements please help me or explain and how to use this libraty (FreqMeasure) in my case (measure the speed of a bicycle).
Thank in advance!
5  Using Arduino / Programming Questions / Re: Delay when receive data from Arduino Nano in first time plug USB cable on: January 22, 2013, 08:32:41 pm
Ok, thank you very much.
6  Using Arduino / Programming Questions / Re: Delay when receive data from Arduino Nano in first time plug USB cable on: January 22, 2013, 08:10:32 pm
Thank! you're right. I'm put Sleep(2000) between opening the serial port and sending the first command ->it works normally
In case, I scan the COM port on the computer to find out portName of Arduino
Assuming my PC has the following ports
+ COM1
+ COM2
+ COM3
+ COM4 (Arduino)
I want to find the COM port of the Arduino. I will send the command to all COM ports, then receive respond
Check if respond properly to the value set under Arduino ->port Aruino found.
Code:
SerialPort ^portSerial = gcnew SerialPort();
portSerial->BaudRate = 9600;
portSerial->Parity = Parity::None;
portSerial->StopBits = StopBits::Two;
portSerial->DataBits = 8;
portSerial->Handshake = Handshake::None;
portSerial->ReadTimeout = 500;
portSerial->WriteTimeout = 500;
array<unsigned char>^request={0xA1};//respond will 0xB1 from arduino
listSerialPorts = portSerial->GetPortNames();
for each(String^ port in listSerialPorts)
{
portSerial->portSerial->PortName = port;
portSerial->Open();
Sleep(2000);
portSerial->Write(request,0,1);
rspFromBoard = portSerial->ReadByte();
if(rspFromBoard == 0xB1)
{
Console::WriteLine("Port Arduino Found");
}
}
->>>So happens in case of Sleep (2000) was repeated. It will create big delay in my app
In this case, how do I do?
7  Using Arduino / Programming Questions / Re: Delay when receive data from Arduino Nano in first time plug USB cable on: January 22, 2013, 06:56:45 pm
Thank you!
At first I think so. But when I use Serial Monitor to send command (on Arduino soft) at In first time plug USB cable --> Board reply immediately
Then I open the my project and send command --> it still fails time out as I said.
As you say, I have set portSerial->ReadTimeOut = 5000 (5s) but it still fails.
But my problem occurs the first time you plug the USB cable.
 
8  Using Arduino / Programming Questions / Delay when receive data from Arduino Nano in first time plug USB cable on: January 22, 2013, 03:23:53 am
Dear all!
I have a problem. Help me please.
Please look at my code.
+ Arduino code:
Code:
#include <FreqMeasure.h>
void setup() {
  Serial.begin(9600);
  FreqMeasure.begin();
}
double frequency=0;
int timeSetZeroFreq=0;
void loop() {
  if(Serial.available()>0)
  {
    switch(Serial.read())
    {
      case 0xA1:
            Serial.write(0xB1);
            delay(10);
            break;
      case 0xA4:
        {
            readFreq();
            byte *frequencyArray = (byte *) &frequency;
            Serial.write(0xB4);
            delay(10);
            Serial.write(frequencyArray[0]);
            delay(10);
            Serial.write(frequencyArray[1]);
            delay(10);
            Serial.write(frequencyArray[2]);
            delay(10);
            Serial.write(frequencyArray[3]);   
            delay(10);
            //Serial.write(frequencyArray,4);     
        }
            break;
      case 0xA8:
        {
            int voltage = analogRead(A0);
            byte * voltageArray = (byte *) &voltage;
            Serial.write(0xB8);
            delay(10);
            Serial.write(voltageArray[0]);
            delay(10);
            Serial.write(voltageArray[1]);
            delay(10);
            //Serial.write(voltageArray,2);
        }
            break;
      default:
            Serial.write(0xC1);
            break;
    }
  }
}
float readFreq()
{
  if (FreqMeasure.available())
      {
        double f = FreqMeasure.read();
        frequency = F_CPU / f;
      }
  else
  {
    timeSetZeroFreq = timeSetZeroFreq + 1;
    if(timeSetZeroFreq>50)
    {
      frequency = 0;
      timeSetZeroFreq = 0;
    }
  }
  return frequency;
}
+ Code in my project (written in C++ use SerialPort Class of Microsoft)
Code:
int main()
{
//initial serial port
SerialPort ^portSerial = gcnew SerialPort();
portSerial->BaudRate = L"COM3";
portSerial->Parity = Parity::None;
portSerial->StopBits = StopBits::Two;
portSerial->DataBits = 8;
portSerial->Handshake = Handshake::None;
portSerial->ReadTimeout = 500;
portSerial->WriteTimeout = 500;
portSerial->Open();
//send request
array<unsigned char>^request={0xA1};
while(1)
{
try
{
portSerial->Write(request,0,1);
//Read respond
       portSerial->ReadByte();
}
catch (System::Exception ^ex)
{
Console::WriteLine("Send Request Error: {0}",ex->Message);
}
}
}
-->My problem: In first time plug USB cable, function portSerial->ReadByte() error TimeOutException. After sending request in the 3rd (use while(1)), data received is true. More detail:
portSerial->Write(request,0,1) in the first time -> portSerial->ReadByte() error timeout
portSerial->Write(request,0,1) in the secondtime -> portSerial->ReadByte() error timeout
portSerial->Write(request,0,1) in the third time -> portSerial->ReadByte() = B1 ->right

But my problem occurs the first time you plug the USB cable. If do not disconnect the USB cable, then everything works normally.
9  Using Arduino / Programming Questions / Select Serial Port On Arduino Soft on: January 15, 2013, 08:07:09 pm
Hi all!
- The first time I plugged the Arduino Nano board into my computer. After the board automatically install the drive, the board is connected to COM3 on my computer.
- On arduino soft, I'm select:
+ Tool-> Board-> Arduino Nano
+ Tool-> Serial Port -> COM3
Then I compile and upload. And everything works normally. I packed products.
----> My question:
If I bring my products to use on another computer. And when I connect my product to this computer, the board is connected to COM4 (not COM3). Thus the program has loaded for the board is working on this computer?
Please help me!
Thank in advance.
10  Using Arduino / Programming Questions / Data Transfer between Arduino Nano and PC on: December 17, 2012, 09:55:14 pm
Hi all!
I'm newbie. Sorry for the inconvenience!
My project:
+ Hardware diagram:

+ Software:
PC: I want to write a program by Visual C++ 2008. I use SerialPort class in MSDN. "Send request to arduino and read sensor value from arduino"
Code:
....................
void readAnalog()
{
//request: send "1" to arduino
........... (help me)
if(serial available)
{
//read analog value from arduino
............ (help me)
}
}
void readFrequency()
{
//request: send "2" to arduino
........... (help me)
if(serial available)
{
//read frequency value from arduino
............ (help me)
}
}
.........................
Arduino Nano: read request from PC and send sensor value to PC
Code:
#include <FreqMeasure.h>
void setup() {
  Serial.begin(57600);
  FreqMeasure.begin();
}
double sum=0;
int count=0;
int temp=0;
int request=0;
double frequency=0;
int voltage=0;

void loop() {
  if(Serial.available()>0)
  {
    request = Serial.read();
    if(request == 2)
    {
      //read frequency from sensor
      readFreq();
     //send "frequency" value to PC
      .............(help me)
    }
    else
    {
      if(request == 1)
      {
        voltage = analogRead(A0);
        //send "anaglog" value to PC
        ............. (help me)
      }
    }
  }
}
double readFreq()
{
  if (FreqMeasure.available())
      {
        // average several reading together
        sum = sum + FreqMeasure.read();
        count = count + 1;
        if (count > 30) {
          frequency = F_CPU / (sum / count);
          sum = 0;
          count = 0;  
        }  
      }
      else
      {
        temp = temp + 1;
        if(temp >3)
        {
          frequency = 0;
          temp = 0;
        }
      }
      return frequency;
}

- If my doing wrong, people fix to help me.
- And if my doing right, please help me complete code in "..........(hepme)"

Thank in advance!
11  Using Arduino / General Electronics / Re: Supply voltage on: December 16, 2012, 08:28:11 pm
That circuit still has the buffer output connected to 5V

I know... but I figured that it's just a mistake in the drawing. Hopefully it's not ACTUALLY wired that way.

You're right. I draw the wrong. It must be like this:


Thank all comments!
12  Using Arduino / General Electronics / Re: Supply voltage on: December 13, 2012, 10:33:49 pm
Thanks your reply!
My purpose: I have a 3D program, my program will read value of sensors from Arduino board throught USB cable.  
+ Hardware:
According to the comments, I have to fix:

Is that right?
  * Frequency_board: Measuring frequency form encoder, sent to PC (my froject is written in VC++2008)
  * Potentiometer: Mesuring analog input (A0 pin), sent to PC (my project ís written in VC++2008)
+ Software:
  *Communication between PC and Arduino board:
      -I am writing an application in VC++2008. I use SerialPort Class (MSDN) (http://msdn.microsoft.com/en-us/library/system.io.ports.serialport.aspx) to read each byte that Arduino board posted
      -On the board,I use "Serial" to read requests from the computer (Serial.read, Serial.ReadBytes) and send the value of the sensor to the computer (Serial.write, Serial.print)
  *Progamming for chip:
      -Analog input: i use function "analogRead(A0)"
      -Frequency from encoder: I used library "FreqMeasure" of Paul Stoffregen (best for 0.1 Hz to 1 kHz)
---->>>>It is my understanding. I'm not sure about my methods. Hope you guide, please!
Thank in advance!
13  Using Arduino / General Electronics / Supply voltage on: December 13, 2012, 05:17:04 am
Hi all!
I'm new bie. Hope everyone help!
I'm using Arduino Nano v3.0 Board (ATM328P).
+ I use one potentiometer. It uses the reference source AREF
+ Frequency_Board uses +5V source on board.
I'm afraid that USB power is not enough to provide in my application
I hope everyone to explaine my problem.
Thank all!
Pages: [1]