Arduino UNO

Home

CNC BF16
CNC Router
CNC Links

3D DLP Printer
UM2+ Dual

Laser_Show
CO2_Laser

Engineering

Stirling

Arduino

VB.NET

VB6 - 3D
VB6 - Simulation
VB6 - Games
VB6 - Other
VB6 - Outsourcing

About

Valide CSS!
It took me a while, for connecting the LCD to the Arduino, due to some library & cable faults.
In the end, I needed to take these steps:
  • Connect short wires from the arduino to your LCD and arduino.
  • Download and copy the LiquidCrystal_I2C library in your arduino 1.0 program.
  • Upload the sample code into the arduino and it will propably work.
  • Download and copy an updated LiquidCrystal_I2C library in your arduino 1.0.1 program.
  • Upload the sample code into the arduino and it will propably work.
  • Don't use long cables! I used a modified USB-cable to connect, but 1.4 meter is way too long for the I2C protocol to handle. Just a small cable (15 cm) is still working.

    I'm using the nice blue DFRobot I2C LCD module 508040.

  • For the emergency + limit switches, I did some speeds tests. By combining both to one Arduino Uno pin, only one pin needs to be checked each time. The analog pin (A3), is also pin number 13+4= 17, which is easier to use for pin decleration. So pin 17 will be used for analogRead and digitalRead speed tests. There is a big timing difference between both functions:

    • analogRead(17): 112 [usec] (Returns a value ranging: 0-1023)
    • digitalRead(17): 4.17 [usec] (Returns True, if value >512)
    That's almost a factor 30!

    That's good news. So during each cnc-step the fast digitalRead() will be used. If there is an error, the voltage should drop below 2.5 [Volt] and then by reading the slow analogRead(), the right switch could be detected.


    For the CNC project, I want to know the best/fastest way to use incomming numbers from the USB. While the Arduino is only able to read one single byte each time, what is the best way to receive a 'long' number (4 bytes)? After searching internet, it was time to do some speed tests.

    Within this test, there are 2 constants:

  • Ascii string array[0-10] for the number,
  • Binair bytes array[0-3] for the same number.
    These array's represents a random incomming number from the USB. So both array's should have the same representation of the same number. Then this number is 1000x converted towards a long number and this time is recorded. The table below, shows a piece of the converting code and the elapsed time.

    AsciiBinair
    1. 10x approach:2. Structure (official):3. Memcpy:4. BitShift:
    long BytesToLong4() {  
      long val = 0;
      val = ((long )binNumber[0]) << 24;
      val |= ((long )binNumber[1]) << 16;
      val |= ((long )binNumber[2]) << 8;
      val |= binNumber[3];
      return val;
    }
    

    Conclusion:

  • The BitShift approach is far the best method!
  • For sending the bytes, it's clear that for birair you only need 4 bytes everytime, while for the ascii code, this is unsure each time. So for shorter numbers, consider the 'integer' or 'byte' types. (Single bytes could be used w/o converting!) ;)


  • Finally my new toy from iprototype.nl has arrived: The famous Arduino Uno (starter package) :)
    Now the fun starts (again)!
    This chip is well documented: www.arduino.cc and very easy to use.
    After reading the first 3 chapters, testing and playing around, I feel comfortable writing some CNC stuff.