close-circle
Close
0%
0%

Access B

Create applications in Visual Studio C# that can communicate with a 18F2550 and use it's peripherals

Similar projects worth following
close
Access B is more a software tool, using two class C# file created with Visual Studio you can create applications to use peripherals of the PIC 18F2550 from microchip, communication between the software and the PIC is with a built in USB module, from simply make an application that toggle a single LED in one of it's 20 GPIO to read an analog value from any of it's 10 analog channels.

History

The first idea was only to control GPIO of the PIC to read digital data (like as parallel port) or control devices (by set on or off it's GPIO) using the 18F2550 built in USB module configures as CDC, but then I want more than that, with a PIC capable of PWM, ADC, Analog comparation, SPI, I2C, USART and voltage reference output it woud be a waste to use only GPIO.

So I want to USB HID inestead, why? well no drivers are needed in any OS, and I want to try something new. First was to configure the USB a HID gamepad and read the data sent, but that was too limiting so I opted for USB HID Custom device, Microchip MLA has a demo for that and I decided to reuse it, with USB HID custom you have 64 bytes per transmission/reception to use for what you want. With this I implement "functional blocks" in firmware that do simple things like configure pheripherals, read the contents of special function registers and send back to Host, read ADC convertions, turn on PWM, etc. by the side of C# I implemented a series of methods that controls all the functional blocks in the firmware of the PIC.

In the end I created two C# class files one to find the device, send data to or retrive data from the PIC and the other have all the methods that control the functional blocks in the firmware of the PIC:

  • AccessB_class.cs (contains all the methods to configure and use the peripherals)
  • AccessB_winusbapi.cs (containts the methods to find and send/retrive data from the PIC)
  • One firmware file for the PIC 18F2550, and a simple PCB desing files in Eagle.

Make your own tools.

AccessB is a very versatile tool, using visual studio and the peripherals of the PIC you can make a tool that meets you needs, a simple SPI/I2C memory dumper, create a GUI to control complex process (using AccessB to interface with electronics devices), Parallel IO for you PC, as the data is processed by the Host, you can retrive data from analog sensors process it with the application (PID control) and take actions with the GPIO, PWM or sending orders to others devices I2C, SPI, USART.

Knowledge is power

Yes you will need to know about Visual studio C# and the internals of the PIC at least have a copy of the datasheet but that isn't a real problem. I had declared all the SFR of the 18F2550 in the class and mapped all the bits from almost all SFR so you can access the SFR using his name, I also defined configurations for the peripherals to ease the task of configuration. Look at some of the simple examples to see how AccessB works.

Manufacturer Tools isn't bad as you think.

All the firmware project is created with MPLABX XC8 and it's based on MLA USB HID Device Custom, and the software class files are made in Visual Studio 2012

Simple Hardware

No special parts are needed, yes In my design I use PIC18F2550 in SOIC package but you can use the PDIP version without problems, you only need a programmer compatible with PIC18F2550. If you need more I/O or peripherals then you can adapt the firmware to work with the bigger version 18F4550 (but you need to add the extra SFR in the class files).

How to see it?

Well AccessB along with the class files allows you to "use" the Board like the PIC18F2550 itself, you will have access to all SFR, if you are familiar with these PIC family you will be using AccessB without problems, and if you never used that PIC in that case there are some configuration macros included to easy the configuration process. AccessB isn't designed to spy communication buses or using it like a logic analyzer, is designed to use as a extension of the PC bringing access to parallel I/O, ADC with 10 multiplexed channels, I2C, SPI, etc. that you can use to communicate with electronic stuff.

Development phase

At this time, the project is on development, for that reason all the firmware code is like spaguetti and with spanish comments, but I will put some order in the code when I finish. In other hand, this is a tool that I want to reuse in a lot of projects that I have in mind, but for now the only...

Read more »

View all 8 components

  • MCP1603 Fail.

    Omar12/07/2017 at 22:57 0 comments

    Well all the four MCP1603 ADJI that I have are dead, I don't know why, all of it release its magic smoke, maybe it does not support change of bottom resistor on the feedback voltage divisor on the fly or maybe I was wrong with something, so suspecting of my voltage level logic converter circuit (based on this) I recycled a 3.3v LDO voltage regulator, desoldered the last failed MCP1603 from the board and performed tests and the five bi direccional logic level converters worked as expected!!!.

    I raised a ticket on microchip about this, I want to know what happened here, if was my fault then why the LDO is not getting hot while I use it? time will tell.

    The next image show the AccessB without the MCP1603 connected to the LDO

  • Return

    Omar12/01/2017 at 23:09 0 comments

    After a year of waiting I added some new things to AccessB design:

    • Changed the USB port from mini to micro
    • Added another micro USB port only for powering the board, this if I want to connect  a cellphone to the AccessB and a wall charger.
    • Added an extra pin to ICSP port to match the six pin of the PicKit 3

     I sent the KiCAD gerber files to PCBWAY and I received this:

    With the boards on my hands I see one mistake: the footprint for the PIC18F2550 was the wrong size, the PIC uses SOIC28 footprint same as the I used on the design so what's wrong??? look at this:

    The PIC uses the Wider version of SOIC28 and I used the Narrow version (I forgot to print the PCB design and check if all parts fit ok) , the solution was easy: convert the SOIC28 Wide to SOIC-SOJ28 and all the PIC pins fit the footprints pads, with C3 too close but not a problem:

    The next step was solder and test the power supply for the voltage level selection part of the voltage level shifter, it output 0.8/1.2/1.8/2.5/3.3 volts without problems, the only down was that MCP1603 ADJI don't support the changue on the fly of the bottom voltage divisor to changue the output, If you do it magick smoke from MCP1603 ADJI comes out, I must dissconnect the board from the USB port and then changue the pin jumper to the voltage ouput that I want and then recconect, I don't know why and I read the datasheet and the evaluation board manual from where I take the design of the power supply and it doesn't mention anything about. I can't check the variable output because I don't have at hand any pot.

    Finally this is the board with almost all soldered:

    Finally I inserted the PicKit 3 on the ISCP port and I see another problem, the capacitor C3 get in the way of the PicKit 3:

    Anyway the AccessB PIC was programmed without problems and was enumerated by the USB por of my laptop and detected by my test software, the next steps will be:

    • Check if AccessB Voltage Level Shifter Works and communicate with a SPI/I2C Devices at 3.3/2.5/1.8/1.2/0.8 volts.
    • Change the SOIC28 Narrow to Wide.
    • Change the position of C3.
    • Point out on the silk screen that P5 (USB micro port) is used only for power and P2 for data and power.
    • Update the Hackaday.io project

    So there is some work to do, see you on the next days.

  • MPLAB XC8 v 1.32

    Omar04/28/2016 at 21:35 2 comments

    Well a little update, if you want to edit/compile without problems this project on MPLAB X you will need to download the old 1.32 version of XC8 to compile the proyect, I had the 1.36 version of XC8 and it don't have plib.h file needed to do some flash erase/write routines, I dont know if the newer version 1.37 of XC8 have the file, I must to try.

    So, you can use the actual version of MPLAB X v3.26 with XC8 v1.32 to compile the project.

    I still waiting to get the funds to order the PCB from OSHpark, so this project isn't dead.

  • It's matter of time...

    Omar01/11/2016 at 23:32 0 comments

    Hi to all.

    Well the project will be stopped for undefined time, yes it's almos done (I only need to order the PCB from Oshpark to end this project) but I don't have the money for now, (well I have it but also I have priorities like wife and daughter), at least I bought all the parts on last December from Digi-key for making three boards, when I have the PCB from Oshpark I will update the log with the good news.

  • Change to KiCAD

    Omar12/07/2015 at 23:30 0 comments

    This project was a really good reason to learn to use another PCB design tools, and I opted to use KICAD for designing the final board, it was hard the first days with KICAD (I always used EAGLE) but nothing that google FU can solve.

    For now I can upload the KICAD design files on GitHub but I will upload to google drive until I can access GitHub.

  • GitHub files update

    Omar11/14/2015 at 22:19 0 comments

    Hi to all.

    On the last update, I change the way of how the methods pass the data to write/read file functions on winusbapi.cs, before the user must declare an byte array of 65 bytes with the value in array[0] = 0 to work properly, this must be hardcoded by the user, I change that so the user declare the most "regulat" 64 bytes array containing the data to be send or to be read, read/write functions will concatenate the 64 bytes array with a 65 bytes array with array[0] = 0 this is more practical but some methods stop to work and I don't solve it in that moment, now that problems are solved ( I hope so) but also I made another changes:

    Related to ADC methods change some variables from UInt16 to UInt32.

    Related to ADC_Val method I change the way of how the data is returned to the user.

    About the new PCB design, Jarrett tell me to use a PIC-controlled buck regulator, but I don't want to add another uC to this board, but the buck idea likes me, so I will use the MCP1306 in its adjustable version to obtain all the voltage levels that I want, here is a document about an evaluation board that I will use.

    Well I need to go now, hasta luego!.

  • Finally UDF!!

    Omar10/28/2015 at 05:22 2 comments

    Finally I implemented UDF in C# class files (AccessB_class.c, AccessB_winusbapi.cs) and the MPLAB X project, now if you want to make your own custom function to be included in AccessB you must open the MPLAB X project and write the code inside the UDF function on the UDF.c file and compile the entire project, then use UDF programmer to open the hex file and click program, it will extract ONLY the UDF opcodes and then it will program all the program data on the 18F2550, you can after call the UDF using the CALL_UDF method.

    UDF support ISR but low priority only, this because high priority interrupts are used by USB module, setting another high priority interrupt source may cause unexpected behaivor on the USB module.

    Another update on the C# class files are the GPIO methods GPIOx, GPIO_DIRx, GPIO_LATCHx give access to PORTx, TRISx, and LATCHx SFR but in a more general way, more experienced PIC uses may prefer to use the TRIS/PORT/LATCH (that is a more direct and fast way to access I/O) and lees experienced PIC users may prefer to use GPIO, well I don't want to enter in to details now so I will make an user guide :)

    The next stage is to design a new PCB, this will include voltage level shifting from 5v to 3.3V / 2.5V / 1.8V / 1.2V in five I/O corresponding to SPI/I2C/USART, and all will be SMD in a double layer PCB.

    All the projects now include the update versions of the C# files, also I included the link to the GitHub repo of the UDF programmer.

  • UDF almost done!

    Omar10/05/2015 at 19:25 0 comments

    UDF is almost done, it need to refine details, for now I tested simple UDF that only change the value of LATB register from 0xAA to 0xBB and viceversa with success, I need to test low priority interrupts with UDF and send/receive data over USB inside the UDF, may be a couple of days more and the software/firmware part of this project will be completed!!..

    The next step will be redesign the board and include logic level shifting to SPI/I2C/USART pins, to interface 5V to 3.3/1.8/1.2 volts.

    When all the UDF part be finished I will upload the source files to GitHub.

  • Working on UDF.

    Omar09/03/2015 at 22:41 0 comments

    It's been a while without updating, but there are a good reason: the birth of my first daughter, but even so I've been working on UDF (User Defined Function) part of Access B.

    After thought for a couple of days I made the decision of don't make a JTAG routines as I had mentioned before, I want to end this project and pass to another projects using the Access B. JTAG can be implemeted through UDF anyway.

    I will redesign the board to include a logic level trasnlator for SPI, I2C and USART (5v to 3.3v).

  • Upload to GitHub

    Omar07/10/2015 at 20:05 0 comments

    Well I uploaded some of the source files and project to GitHub, the source files from microchip still be in google drive for a couple of days and then I will move to GitHub too.

    The AccessB MPLABX project compile with no errors but there is some issues:

    • The problem with SPI that I mentioned before was resolved.
    • I'm working on EUSART module firmware and class code so isn't work correctly.

View all 22 project logs

Enjoy this project?

Share

Discussions

Jan Zumwalt wrote 03/01/2016 at 06:31 point

So, where are the files?

  Are you sure? yes | no

Omar wrote 03/01/2016 at 19:41 point

On GitHub, the links are on the top of this page below photos.

  Are you sure? yes | no

Adam Vadala-Roth wrote 06/27/2015 at 00:51 point

Hey! Neat project, have you seen this one? (https://hackaday.io/project/3185-dyio-dynamic-input-output-controller) it bears some similarities, you might be interested in it, rock on!

  Are you sure? yes | no

Omar wrote 06/27/2015 at 01:25 point

Thanks!, yes both are similar we have the same goal.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates