Asked — Edited

How Many Lines Can Be Added To An EZ-Script

i have a design that works perfect but uses arduino board (i know you care for it ) but here is the problem been looking to slove for a long time its a SPECTROMETER i guess you know what it is now it uses 7 leds of differnet color of the spectrum including IR AND UV and photo dide to ADC input that look easy now hard part the code from arduino BOARD TO YOURS very long code because each led has a value plus a code to go with it times 7 for each sample of liquid,plus other codes then start up code and automatic code righter when you push a button for sample under test it rights the code and serial code to lcd

can it be done with your great board and have any ideas,great sensor for robotics on liquids,i want it mostly to tell different bar drinks apart and BEER


ARC Pro

Upgrade to ARC Pro

Synthiam ARC Pro is a new tool that will help unleash your creativity with programming robots in just seconds!

PRO
Synthiam
#1  

There is no limit to the code size, really. I mean, there probably is a limit but you're not going to reach it.

I'm certain everyone on this forum is excited to see you build a robot. I would recommend building an EZ-Robot first. Load ARC and follow the Tutorials and build an EZ-Robot to understand how ARC works. Once you have built your first robot, you will be familiar with the controls and how to build your next robot or expand onto it. You can also begin adding your advanced features with EZ-Script. You may find that EZ-Script fulfills your needs... If not, then switch to C# or VB .Net :)

Your requirements can be done easily once you start building a robot. Your requirements have nothing to do with the board itself. The EZ-SDK was designed for advanced custom robots. To begin with programming, I would begin by taking a course in C# or VB .Net to learn the basics of programming in those environments.

The EZ-BoxBox can be found in the tutorial section, and is a great starter project. It will help you learn how to build an EZ-Robot. Building the BoxBox will help you understand the process to building a robot.

There is a process to building a robot, I would recommend following the Tutorial section to build a robot. Once you have a robot, you can then begin adding features like this request.

#2  

you dont need to build a robot to work on the codes,some days i try the board and examples to get use to it ,and some days i work on the robots as parts come in i give you these ideas for add-ons now so maybe 3 months or 6 months or a year it may be out you have so many people asking you for add-ons writing the code on the arduino not done by me,so i dont know how to use it on EZB my omnibot should be finish fairly soon,i do have another in site 90% done IROBOT ROOMBA project it has it mostly wired up with ezb mounted only stop because of my main project my omnibot 2000 design first.just like others like my friend JOSH i think he has 3 started too not finished will try the boxbox idea wednesday night

update i look at the boxbot idea ,way too easy for me i just use the board only hook a few servos and try the code,and same with sensors too ,on my bench,that best way to get use to the ARC and using the examples,i call it a breadboard idea

PRO
Synthiam
#3  

One of the things I would recommend is modifying the code to read from a text file. That way you can obtain the liquid type form a text file.

I suspect the sensor reads ADC? If so, create a comma separated text file in Excel with the ADC range of each liquid. Then you only need to do something like this...

In your CSV:

  1. the first column is the minimum ADC value for the liquid
  2. the second column is the maximum ADC value for the liquid
  3. the third column is the name of the liquid

Here is an example CSV... [feature] 10, 15, Beer 20, 28, Water 30, 45, Oil 66, 80, Hair Gel 90, 95, Banana 120, 160, DJ 170, 185, Milk 190, 210, Vanilla Ice Cream Yummmmmm [/feature]

Here is the EZ-Script code...


$filename = "c:\robot\liquids.csv"

if (FileExists($filename) = false)
  print("$filename does not exist!")
  halt()
endif

# Get the value from the sensor
$value = GetADC(adc0)

FileReadReset($filename)

# Loop through the file to find the matching value
:START

  # Read the line of text from the file
  $line = ReadLine($filename)
  

  # Split the line of text into fields and use a COMMA as the separator
  # Because the file was created in Excel as a CSV
  $fieldMin = split($line, ",", 0)
  $fieldMax = split($line, ",", 1)
  $fieldName = split($line, ",", 2)

  # Check if the ADC value is within the range of the field
  if ($value > $fieldMin and $value < $fieldMax)
    print("Match found!")
    print("Detected liquid is: $fieldName")
    halt()
  endif

  # Reached the end of the file, must not be a match
  if (FileReadEnd($filename))
    print("Did not find match")
    halt()
  endif

goto(START)

Voila! That's an incredibly simple and elegant solution. Way better than the Arduino code :)

#4  

WILL TRY IT THIS WEEKEND, how does the automatic function work hard to get all those values and there is 7 of them too so how do you add 7 values from one ADC very funny DJ 120,160 ARE YOU A LIQUID

DONT have or never use EXCEL i guess wordpad or notepad be ok and change csv to txt

WILL TRY IT THIS WEEKEND, how does the automatic function work

very funny DJ 120,160 ARE YOU A LIQUID

WILL find the code and post a example of the code

#5  

// variable declaration int inPinRed = 3; // red button on pin 3 int inPinBlack = 2; // black button on pin 2 int redState; // is red button pressed int blackState; // is black button pressed int val = 0; int analogPin = 1; // sensor output connected to Analog Pin 1 int sensorValue = 0; // variable to store the ADC value of the photodiode int red = 6; // red led on output pin 6 int yellow = 7; // yellow led on output pin 7 int ir = 8; // IR led on output pin 8 int blue = 9; // blue led on output pin 9 int orange = 10; // orange led on output pin 10 int pinArray[] = {6, 7, 8, 9, 10}; // pin address array int count = 0; // for next loop counter int sampleValue[5]; // sample value array int windex[] = {38,1019,564,321,315}; // database values for windex int windexValue; // windex value int windexTemp = 0; // windex value - sensor value for ID int motoroil[] = {31,1020,787,283,193}; int motoroilValue; int motoroilTemp = 0; int coffee[] = {38,993,41,351,286}; int coffeeValue; int coffeeTemp = 0; int softsoap[] = {31,1020,708,379,58}; int softsoapValue; int softsoapTemp = 0; int water[] = {33,1017,582,327,45};

here is part of it

PRO
Synthiam
#6  

That's terribly written code. Absolutely terrible!

However, I do see that there are 5 values per reading. So you will need to modify the code to split by more fields. And it doesn't look like a range, so simply use the EQUAL sign instead within the IF condition.

Ugh, that code hurts my eyes :(. Creating separate variable arrays for each "liquid" is an example of very bad programming. The example I demonstrated to you in my above post will read from a file to find the appropriate matching liquid - and only be a few lines of code... Rather than a billion lines of IF conditions like I imagine that one to be.

You can even create a learn feature to write new lines to your CSV. So you can teach your robot new liquids.

#7  

it was done by a guy who sell real good spectrometers from his business some over $1000,but they are pro versions and not using arduino board,made it for others using arduino boards just something simple for others using the arduino board automatic code add in code near bottom i think,you put a sample press i think red button and code values are entered,on lcd you do need to name it code is only pages on txt file i know so how would you use the learn function

#8  

here is the learn function learn: // learn subroutine clearLCD(); Serial.print(" Learn Mode "); for (count=0;count<5;count++) { digitalWrite(pinArray[count], HIGH); //turn the led on delay(100); // wait for stabilization sensorValue = analogRead(analogPin); // read the value from the sensor if (sensorValue <= 99) // test for number of digits to display {Serial.print(32, BYTE); // insert space } if (sensorValue <= 9) // test for number of digits to display {Serial.print(32, BYTE); // insert space } Serial.print(sensorValue),Serial.print("-"); //send as a ascii encoded number delay(30); if (count == 0) {Serial.print("Red ");

as you can see half the code is for LCD

#9  

I really enjoyed this thread. I'm sure many people have learned something from it.


 read

;) code

#10  

Yes DJ did a very very good job on the code like always looking soon to post the very easy circuit,made some changes in the design ,like making the leds put out more output added more color spectrum,i added IR AND UV to get better accuracy and range plus got in SMT leds and photodiode to make it much much smaller.

But it will take some time,i have my omnibot 2000 to finish first,but my gecko cage project might need faster,since FEB 14 HAVING THEM MATED and few months latter baboies ,yes yes yes,ggoing to be another daddy soon,since they need help to hatch,feb 14 a very big day for me and my girlfriend since she holding the lady netri and i have jake

DJ what do you meen by EQUAL sign with the IF I dont know what each one meens or how to use it,have any info on it