Vex On-Line Controller Code v2.x (Available Source Version 0.80 Beta)

Any feedback, Negative or Otherwise on the Vex On-Line Controller Code v2.x (Available Source Version 0.80 Beta)??

I am revamping the I/O Block setup. I think you will like the flexibility. You will set it up like EasyC does for the ‘C’ Compiler, and the Output Data will be changed Automatically.

But I have a Quandary… It is a limitation of the formatting of the I/O Block data. The Format does not lend itself to being flexible in the number and Types of Data, By Its Self.

IF you are going to only have ONLY ONE I/O Block format for the duration of your Program, and you don’t mind having ALL the DATA, ALL the TIME, this won’t be an issue. But I would like to see some options.


First, as you change the Data Types, the amount of Bytes will vary. It won’t be an issue if you use the Spaces (0x20) as delimiters, but the Overall Receive Buffer Length requirements will vary (make sure you plan for the Worst Case), plus you can have the potential to mis-interpret the incoming data if your PC program is looking for a Different Format than the Vex Program is providing (There is no DATA VALIDATION).

=========================================================================
The “default format” of the I/O Block is 54 Bytes, in ASCII:
“BOARDDATA 1018 1022 1022 1022 1 1 1 1 1 1 1 1 1 1 1 1\r”

This data represents 4 Analog Inputs, 6 Digital Inputs and 6 Interrupts (Inputs) which is broken down like this:
"BOARDDATA " // Header
"1018 1022 1022 1022 " // Analog Inputs
"1 1 1 1 1 1 " // Digital Inputs
“1 1 1 1 1 1\r” // Interrupt Inputs

There are 16 Data Items.

This is the ONLY DATA FORMAT the IFI/intelitek Loader On-Line Window supports.

=========================================================================

IF YOU needed 8 Analogs Inputs and 2 Digital Inputs (and the same 6 Interrupts), it would look like this:
“BOARDDATA 1018 1022 1022 1022 1022 1022 1022 1022 1 1 1 1 1 1 1 1\r”

Which is broken down like this:
"BOARDDATA " // Header
"1018 1022 1022 1022 1022 1022 1022 1022 " // Analog Inputs
"1 1 " // Digital Inputs
“1 1 1 1 1 1\r” // Interrupt Inputs

And the I/O Block is now 66 Bytes, in ASCII, but the number of Data Items is the same, 16.

=========================================================================

Running a PC Program looking for the DATA from the first Vex Program, with the Second Vex Program will most likely get you no actual Digital Input Data for Inputs 5-8.


Second, if the DATA for a given Input has not changed, its Value is still transmitted to the PC Program, because the ASCII format above is Positional and needs to have all Data Elements to be Parsed (Processed) correctly.


Third, the ASCII format is easy to read in the Terminal Program, and easy to work with in your PC Program, but is Wasteful in the number of Data Bytes used to transmit from the Vex Controller to the PC.

=========================================================================

Example Same Data in ASCII and then BINARY:
“BOARDDATA 1018 1022 1022 1022 1 1 1 1 1 1 1 1 1 1 1 1\r” 54 Bytes in ASCII.

0x42 0x4F 0x41 0x12 0x44 0x44 0x41 0x14 0x41 0x03 0xFA 0x03 0xFE 0x03 0xFE 0x03 0xFE 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 33 Bytes in Binary.

Note that in the Binary, “BOARDDATA” is still the same, but there are no Spaces, because each Analog Value is 2 Bytes (High Order Byte first), and each Digital Input has its own Byte.


A final note about the Binary Format, if an Identifier Byte was added to each Data Element, they could be sent in Any Order, or even skipped, further reducing the amount of Traffic on the Serial Lines.

I am partial to reporting the I/O Block data in Binary verses in ASCII, but YOU are the ones that are using the Program, so I solicit your Input. :wink:

In case you did not know, my Day Job is all about working with different Computer Devices, communicating with different Hardware Standards (RS-232, RS-485, and CAN), and Software Standards (SAE J1708/J1587, SAE J1939, RV-C, and Proprietary) . I live this stuff everyday!! And I love it!!!

Vex On-Line Controller Code v2.0 (Available Source Version 0.81 Beta)

***** Updated to release 0.81b *****

Added with v0.81B

ANALOG/DIGITAL I/O is now selectable with a Single Function Call,
“DefineControllerIO()”.

Function “OnLine_Broadcast()” automatically prints out the correct number of
ANALOG and DIGITAL INPUTS.

Supports OUTPUT Control of I/O Ports 01-10, if you are not using them for INPUT.

Any Feedback? Anyone??? THUMP THUMP… Hello, is this thing on! :wink:

What you have done is pretty cool, and I am starting to appreciate it more by the minute. However many of our Vex forum members, including myself (hardly an advanced programmer), probably have problems understanding *Vex code jargon *and therefore do no post comments. If you could provide a simplified summary of what you have accomplished (which by the way is pretty amazing) that would be great.

Good Job :slight_smile:

Technic-R-C

WOW I just downloaded MPLAB and it is amazing. The ifi_startup, utilities, etc. code is amazing. I have been looking through it and I am starting to understand the nitty gritty technical stuff about the Vex controller code.
Quick questions: Will I be able to write code in this MPLAB student edition and transfer it to my robot just like any other code. After reading the websites and links provided, common sense dictates yes (but I’m just checking).
also…
Would this version of the program be allowed to be used during the Elevation competition?

Technic-R-C

Hmm… You Right…

The “Vex code jargon” is a little more than most people are ready for. But I wanted to start somewhere that has not been explored very well. Since most everyone is at a different level, there are a lot of places one could start.

What would help you the most?

I wrote this code to mimic the Vex On-Line Code, so that someone like you could see (once you can understand a little ‘C’ Code) how the Vex Controller communicates with the PC On-Line Window Program. And then change the Vex Code, or better yet, write your own PC Program (like a dashboard program) to run the Vex Code.

Think of what you would like to try with the Supported Sensors, and try it.

That is great!! You will find that it looks just like a lot of other embedded projects. If you have questions, just ask, because if you don’t know the answer, there is bound to be 3 or 4 more who don’t either, but are not quite sure how to ask… :wink:

Yes, when you use EasyC, it guides you in writing correct ‘C’ Code, and when you compile, it brings all the pieces together and sends them to the same MCC18 compiler that is used by MPLAB to compile the VEX Starter Code.

Yes, the “Elevation - Appendix D (Programming Guide) coming soon” is still pending, but the VEX Starter Code is what the purchasers of the MP LAB IDE use to get started. You can also request the complete Vex Default Code by e-mail. You just add it to the Vex Starter Code, copy the Vex Starter Code project to a new Project Name, replace the two User Code Modules and re-compile.

Any Questions, please ask… There is POWER in Programming!!

I completely agree, Programming is POWER… however I need some help

Here are a couple of questions that I need some insight on.

  1. What is the difference between VexUserCode.mcp and VexUserCode_DDT.mcp (Dynamic Debug Tool?) Which project is the one that has to be modified in order for the microcontroller to perform a task?

  2. For the source codes, is the user_routines.c source file the only one that needs to be edited when making code? Basically, is this the file that makes the microcontroller process written code? Same questions about user_routines_fast.c? In the description both of these are supposedly the files that are supposed to be edited, can you confirm?

  3. When I attempt to open the VexUserCode_OL2 as a project, nothing shows up… Any ideas?

  4. I understand that this is a MPLAB trial version, but the functions that will be disabled after 60 days are not really clear to me. Will the program work for my future programming or will I have to purchase the full version.

So many questions… hope you can help

Technic-R-C

I discovered that POWER at age 16, JAN-1982 with a Apple ]+, 48K RAM.

OK…

(Bare with me, I keep going in “logical circles” here describing this… :wink: )

VexUserCode.mcp (this is called the Project [see below]) is the Vex Starter Code (almost like the Vex Default Code, but a little less complex). The “Vex Starter Code” will process DATA from the RX port (RX1) and use that data to change the PWM (Motors and Servos) ports.

VexUserCode_DDT.mcp (still called the Project [see below]) is the Vex Starter Code minus the Reading of the RX port, but adds processing data from the Serial Port to change the PWM and Outputs, and also sends from the Serial Port DATA about Analog and Digital Inputs

They both perform tasks on the Micro Controller, just slightly different ones.

Q2P1: For the most part, YES. Each Project (“VexUserCode.mcp”, “VexUserCode_DDT.mcp”, “VexUserCode_OL2.mcp”, ect…) has its own “user_routines.c” and “user_routines_fast.c” (“user_routines.c” and “user_routines_fast.c”, “user_routines_DDT.c” and “user_routines_fast_DDT.c”, “user_routines_OL2.c” and “user_routines_fast_OL2.c”, ect…).
Q2P2: All the “.c” and “.asm” files can create Code that the micro controller can process. “.h” files are definitions and the “.lib” files contain prevously compiled Code.
Q2P3: (Same answer as Q2P1)
Q2P4: (Same answer as Q2P1)

If you click on the Windows Menu Item, at the bottom of the Drop Down, are there any Windows labeled, “Output” or “VexUserCode_OL2.mcw”?

Make sure that you have unziped the VEX Starter Code into a directory and then unziped the Vex On-Line Controller Code v2.x into the same directory, because the “Vex On-Line Controller Code v2.x” needs files from the “VEX Starter Code” in order to Compile.

When you do a Project->Open, and select the “VexUserCode.mcp” Project, it should show a Work Space like Image 20080923-001.JPG. The “VexUserCode.mcw” Windows is your “Project”, which is the ‘C’ Source Files, ‘C’ Header Files and Libraries (and Linker Information) which when Compiled makes the program that is downloaded to the Vex Controller. The two main files are “user_routines.c” and “user_routines_fast.c”.

When you do a Project->Open, and select the “VexUserCode_DDT.mcp” Project, it should show a Work Space like Image 20080923-002.JPG. The “VexUserCode_DDT.mcw” Windows is your “Project”, which is the ‘C’ Source Files, ‘ASM’ Source Files, ‘C’ Header Files and Libraries (and Linker Information) which when Compiled makes the program that is downloaded to the Vex Controller. The two main files are “user_routines_DDT.c” and “user_routines_fast_DDT.c”, plus the “PicSerialDrv.c” and “PicSerialDrv.h”.

When you do a Project->Open, and select the “VexUserCode_OL2.mcp” Project, it should show a Work Space like Image 20080923-003.JPG. The “VexUserCode_OL2.mcw” Windows is your “Project”, which is the ‘C’ Source Files, ‘ASM’ Source Files, ‘C’ Header Files and Libraries (and Linker Information) which when Compiled makes the program that is downloaded to the Vex Controller. The two main files are “user_routines_DDT.c” and “user_routines_fast_DDT.c”, plus the “PicSerialDrv.c” and “PicSerialDrv.h”, plus the sensor configuration code I added in, “mdo_sensors.c” and “mdo_sensors.h”.

MPLAB is the IDE, there are no limitation. The 60 Days are for the Student version of the MCC18 ‘C’ compiler, and that won’t matter for the Vex programs. The Student Version of mcc18 is what is included with EasyC.

Oh course… I have been there before…
20080923-001.JPG
20080923-002.JPG
20080923-003.JPG

I forgot to add info about the user_routines.c and the user_routines_fast.c files.

The Vex Controller has Two PIC Processors in it. They are called the Master and the User. The Master Processor is only programmed by IFI (VexLabs), but the users (That is You an Me) can Re-Program the User Processor.

Because the Master is in charge of User, and only has updated information every 18.5ms, the Code in the user_routines.c is only called every 18.5ms. This would be for efficiency, just like you don’t check the Mailbox, Five Times a day for Mail, when it only comes Once a Day at Noon.

Once every 18.5ms is too slow for things like Ultrasonic Sensors and Encoders to be monitored accurately. So there is the the user_routines_fast.c module, that is called every time the main loop is run, which is a whole lot faster.

Remember that not all the functions in user_routines.c and the user_routines_fast.c files will be called, just certain ones.

Some more background about the ‘C’ Programming Language. (These are “standard” things, that ‘C’ does, and can be done differently, just so you know) .

The first function that is called in your program is always called main. main is the Entry Function of our User Code, and all other functions are called from it, or called from functions called from the main function.

‘C’ Programs in a Computer Environment (like your PC) will eventually need to exit. When the end of the main function is reached, it will then return to the StartUp code that called the main. But in an Embedded System, the main should never exit, it should loop forever (e.g. while (1) { })

Sorry for the late reply

Thanks for all the help MarkO, I got it working great.

Technic-R-C