PIC16F1827 connected to Android USB via
OTG cable and UART to USB module. Controls 4 inputs, 4 outputs, and 2 analogue inputs. Switch 4 PIC outputs by the toggle
switches and read 4 inputs by the 4 lights, read voltage of 2 analogue
inputs. 10 bits analog is transmited in one byte of 7 LSB and another byte of 3 MSB. The Arduino update data every second.
The app is in free program Basic for Android (B4A) https://www.b4x.com/. Transfer APK file
to your Android device and install the app by opening the file.
USB-UART can be bought from eBay: https://www.ebay.co.uk/sch/i.html?_from=R40&_trksid=p3519243.m570.l1311&_nkw=usb+to+uart
Using PIC18F2550 for connecting analogue
and digital signals to USB port . Included Visual Basic 6 code, VS2005 C++ and C# codes are based on Microchip code, PIC ASM code, PIC C code and a circuit diagram. The PIC microcontroller
has 10 bit analogue to digital converter. The circuit is powered
by the USB. The interface to the PC is HID class.
The inputs and outputs are updated every 10ms. HID class (human interface device) is a class of
devices like the mouse and the keyboard, the data transfer rate
is limited to 64KB/S. The PC already has a driver for HID USB. VB6 code includes guidance to setting up the PC.
The PC register the PID and VID (product ID) of the USB device when
it's plugged, the VB code uses these ID's to communicate with the
device. For commercial VID it is needed to buy it from USB-IF, but in your lab you can use any number. The source code is derived from freeware from these sources: http://janaxelson.com/usb.htm , http://openprog.altervista.org/USB_firm_eng.html
PIC18F2550
Pins 2-5 are the analogue inputs, voltage range 0 to 5V. Max input voltage
is 5.5V . 1K resistors are to protect the PIC.
Pins 25-28 are the digital inputs, TTL voltage levels.
Pins 21-24 are the digital outputs, they can sink or source 16mA.
Pin 14 is 3.3V internal supply for the USB transceiver. 0.22uF is
required for regulation.
Pins 15,16 are the data lines to the USB connector on the PC.
Pin 20 is the PC 5V powering the PIC. It is limited to 100mA by
the PC. 0.47uF is for decoupling.
For USB wiring info: http://www.interfacebus.com/Design_Connector_USB.html
ARDUINO INPUTS OUTPUTS FOR PC
Using PC to connect to Arduino Uno.
Included Visual Basic 6 code and arduino code. The VB6 may need an ActiveX
file downloaded from Microsoft. The VB app connects to the Arduino via
the COM PORT that the USB drive created and connects the Arduino IDE, when
the VB app is running you cannot program the Arduino. You need to enter to
the VB app the port number in the way it is done with the IDE. The app
displays 4 analogue inputs A0-A3, 6 digital inputs D2-D7 and 6 digital
outputs D8-D13
Code and app for PC Visual Studio 2010 can be downloaded
from GitHub:
https://github.com/projects22/Arduino-Input-Outputs-to-PC app
setup is in usb io/publish
You are free to use the Arduino code and the VB software with no
limitations.
ARDUINO INPUTS OUTPUTS FOR CHROME BROWSER
Using PC to connect to Arduino inputs and outputs. Digital inputs D2-D5 and digital
outputs D6-D9. Arduino inputs HIGH level displayed in green and input LOW level displayed in red. HTML file includes javascript.
The temperature can be displayed in Chrome, Edge and Opera browsers https://developer.chrome.com/en/articles/serial/#browser-support . Run the Arduino connected to PC, open file web_io.html in the browser and click Connect.
You are free to use the Arduino code and the VB software with no
limitations.
ARDUINO INPUTS OUTPUTS FOR ANDROID USB
Arduino connected to Android USB via
OTG cable, controls 4 inputs, 4 outputs, analogue inputs and temperature
sensor DS21B20. Switch 4 Arduino outputs by the toggle
switches and read 4 inputs by the 4 lights, read voltage of 2 analogue
inputs. The Arduino update data every second.
The app is in free program Basic for Android (B4A) https://www.b4x.com/. Transfer APK file
to your Android device and install the app by opening the file.
ARDUINO INPUTS OUTPUTS FOR ANDROID
BLUETOOTH
Arduino connected to Android USB via
HC-05 Bluetooth module, controls 4 inputs, 4 outputs, analogue inputs,
temperature sensor and analogue output (PWM). Switch 4 Arduino outputs by the toggle
switches and read 4 inputs by the 4 lights, read voltage of 2 analogue
inputs. The Arduino update data every second.
The app is in free program Basic for Android (B4A) https://www.b4x.com/. Transfer APK file
to your Android device and install the app by opening the file.
4K7 is a pullup for DS18B20
1K is to reduce the 5V
output of Arduino to 3.3V RX input of the HC-05.
HC-05 is not used in
USB interface, connect Arduino to Android device using OTG cable.
All
inputs or outputs are optional.
02.08.2021 - 14:20 Name: Comment: Thank you for the correction of download link
18.07.2021 - 11:24 Name: asitha Comment: i unable to find vb code for pic18F2550 digital & analog input/output. Can you pls give me the link..
11.05.2019 - 14:49 Name: kanishka Comment: I have downoad ur this project was woking errorless but now vb 6 module has error. moty i just tried on two computers but vb 6 dosent coneect with pic.thank u
31.01.2019 - 20:40 Name: Nasik Comment: Thanks you sir for ur response my OS is windows 7 even it's not working to me it's ok sir I'll try my best to work on
31.01.2019 - 20:36 Name: Nasik Comment: Hi I'm using arduino to communicate with vb6 but it's not working
Can u give me the circuit diagram for arduino plz
29.01.2019 - 23:43 Name: Moty Comment: Hi Nasik,
There is no real need for a circuit diagram, The analog inputs are A0 to A3, digital inputs 2-7 and digital outputs 8-13. You can connect them to what you need.
Some projects may not work with Windows 10.
29.01.2019 - 15:16 Name: Nasik Comment: Hi I'm using arduino to communicate with vb6 but it's not working
Can u give me the circuit diagram for arduino plz
25.09.2018 - 17:26 Name: Carlos Comment: forgot to mention am planning to use a 18f4550
25.09.2018 - 17:25 Name: Carlos Comment: hi moty, great samples you made about usb-uC-PC, thanks a lot for sharing this, have one question: i would like to install a bootloader for the sole purpose of programming hex, should it works if offset the usbio.hex after the bootloader hex?
man thanks Moty
23.07.2018 - 23:21 Name: Moty Comment: Hi John, I made an error with the VB code. Please download it again and try it.
23.07.2018 - 16:58 Name: John Comment: Arduino_io.exe will not run and reports runtime error 8002, Invalid port number. can you help fix this. Thanks
24.04.2015 - 13:32 Name: Moty
Comment: Hi Stain, it written in the description above what program, you cannot use XC8.
24.04.2015 - 12:18 Name: stain Comment: Which program used for compile ASM code & C code plz help me . email: an1997zs@gmail.com
24.04.2015 - 12:17 Name: stain Comment: Which program used for compile ASM code & C code plz help me . email: an1997zs@gmail.com
17.04.2015 - 18:23 Name: Moty Comment: Sorry Aymen, I don't understand the question.
The last answer I sent was for ASM
17.04.2015 - 13:55 Name: aymen Comment: hi moty
how I can change the main program asm code (hand) to properly adjust c code on my work. when I have commented on the application code does not work
14.04.2015 - 01:32 Name: aymen Comment: i change the build to mpsam c18 but is not work again
14.04.2015 - 01:31 Name: aymen Comment: but the code is on assembleur nort on C ????
14.04.2015 - 00:25 Name: Moty
Comment: You have to change the 'Build Option' settings from 'Generate absolute code' to 'Generate relocatable code' :
Menu > Project > Build Options > Project,
In the window select MPASM/C17/C18,
select 'Generate relocatable code',
Click OK
13.04.2015 - 17:12 Name: Moty
Comment: Hi Aymen, for asm use MPLAB 8.xx , you cannot use MPLAB X. Make sure your MPLAB is configured for PIC18F2550 MPLAB has compiler for ASM code.
Copy to the comments the errors maybe I'll be able to tell what is the problem.
13.04.2015 - 15:30 Name: aymen Comment: please help me
13.04.2015 - 13:41 Name: aymen Comment: is not work ???????
13.04.2015 - 13:26 Name: aymen Comment: many errors ?????? What you use the compiler in mplab ide ????
13.04.2015 - 13:24 Name: aymen Comment: i use asm but the compilation not work ???
13.04.2015 - 13:06 Name: Moty Comment: If you are using ASM put in your project the 3 files in ASM folder, usb io.asm has the main code. If you use C put in your project the 4 files in C-GPL folder, main.c has the main code.
13.04.2015 - 03:25 Name: aymen Comment: what about the file .asm adn . inc ??? and the file asm is the file of the application of the inpout outpout er the file main.c ???
13.04.2015 - 03:25 Name: aymen Comment: what about the file .asm adn . inc ??? and the file asm is the file of the application of the inpout outpout er the file main.c ???
13.04.2015 - 03:12 Name: aymen Comment: what the name of file to add all the file please ???????
10.04.2015 - 00:56 Name: Moty Comment: Hi Mohamed. Maybe I'll be able to fix it when I see the project that is similar to mine, do you have a link to the project? Are you using my pic software with a different VB6 program?
09.04.2015 - 21:29 Name: Mohamed Sayed Comment: Moty. In a project similar to yours .the VB6 cannot send bytes to hardware. When I run the software for the 1st time and wait a while then press toggle LED button, Number of written bytes are 0 and no bytes were sent to hardware.. But when I don't wait and press the button just once the Form loads, It sends data .. Do you know how to fix that ???
03.12.2014 - 01:55 Name: Moty Comment: Use the ASM files with the MPLAB if you don't have C-18 compiler
02.12.2014 - 07:19 Name: tharindu Comment: moty iam added my project to the 2 C files and the 2 headers files (h). after iam compiled it. it have more error in compile iam used mikroproc for compile to it.
moty please give me step for compile it.
02.12.2014 - 05:48 Name: tharindu Comment: thank you moty thank you
your project is very impotent to me
i am study one by one day by day
very soon
it will be a newest invention or production Rio Electronic
02.12.2014 - 00:33 Name: Moty Comment: Hi Tharindu, you have to add to your project the 2 C files and the 2 headers files (h) to be able to compile it.
01.12.2014 - 17:17 Name: tharindu Comment: moty cannot compile asm and c file into hex
but ur hex file is working carefully
01.12.2014 - 15:37 Name: tharindu Comment: moty i am downloaded this project but have a two c file.
what is the real file to re-assign the PIC pins.
30.10.2014 - 15:22 Name: Moty Comment: Hi Fabio. I don't but there must be some on the net.
29.10.2014 - 21:47 Name: Fabio Comment: Hi Moty,
Do you have any exemples on how to use a Rotary encoder?
Rgds
29.10.2014 - 21:42 Name: Fabio Comment: Hi Moty,
Do you have any exemples on how to use a Rotary encoder?
Rgds
25.08.2014 - 10:51 Name: Moty Comment: Thanks, it was fun too.
24.08.2014 - 08:54 Name: El ismail Comment: It took a lot of effort & generosity to give out a reliable work like this one. Thanks moty.
14.08.2014 - 20:10 Name: Moty
Comment: Hi Fabio,
You can have up to 6 analogue inputs on the PIC18F2550. I don't have an example for that. I don't know why you can't have 2 USB devices working together on your PC, I have 2 devices working on my WIN XP PC.
14.08.2014 - 00:27 Name: Fabio Comment: Hi, this is a very good Project and it�s working great, but I would like to have 5 or 6 analog input. Is it possible to have such inputs? If so, where do I have to change on the program? Could you send me any example? Another problem I see is when I attach more then one devices, even with diferente PID&VID, the first device is disconnected by the second one.
14.04.2014 - 21:55 Name: Moty Comment: Hi Rathish, I don't have problems with Win 7 for this project. My firmware is for pic18f2550.
14.04.2014 - 13:29 Name: rathish Comment: Hi ,
Few months before I download your usb 4 adc input program ,first time it was worked with my 18f4550 chip. recently I use the same chip for the same program. My os win7 now not recognizing it. My os also shows it is counterfeit problems.
26.10.2013 - 15:34 Name: Moty Comment: Hi Tharindu
It is possible to add 4 outputs. To do that you need to re-assign the PIC pins, rewrite the PIC code and to rewrite the VB code.
I don't have the prototype so I can't try it.
26.10.2013 - 03:25 Name: tharindu Comment: your program for to 4 out put but i want to 8 out how program asm code give me simple example
15.09.2013 - 23:40 Name: matteo Comment: hello, thank you for answering.
I do not care to lower the full scale, I would like to read value in the corresponding voltage. I'm not able to modify the source code visual basic. if possible I would like it to be displayed with 50V input 5V in analog inputs.
thanks, see you soon!
15.09.2013 - 23:39 Name: matteo Comment: hello, thank you for answering.
I do not care to lower the full scale, I would like to read value in the corresponding voltage. I'm not able to modify the source code visual basic. if possible I would like it to be displayed with 50V input 5V in analog inputs.
thanks, see you soon!
14.09.2013 - 22:36 Name: Moty Comment: Hi Matteo.
The VB program can be changed to have less than 5V full scale. Can you change the VB source code yourself? if not I can do it for you after you let me know what voltages you want to read.
14.09.2013 - 17:31 Name: matteo Comment: hello, have matteo, from Italy.
I tested your project and works very well!
I would like to ask a change, you can add each voltage next to scroll bars each voltage in volts (ej.: 2.8V 4.5V etc.)?
thank you very much, please contact me on my mail shark97@tiscali.it
my english is bad!
02.04.2013 - 01:17 Name: Moty Comment: Hi Israel,
I could find Master-Prog information in Spanish only. It appears like people have problems using it. Check if you can find people's comments on using it on pic18f2550. If I find something I'll let you know. It is difficult for me to tell what can be the problem without looking at your setup.
01.04.2013 - 04:52 Name: Israel Comment: Monty, and downloaded the usb counter, my PC still does not know the device, and so I switched Proto and nothing happens. I have some questions:
If the pic is wrong, the developer should give me an error, is not it? In this case would have to change pic. (For me the pic work properly)
If the developer is wrong, you also send me a write error, no? (but I programmed correctly with this device)
01.04.2013 - 04:23 Name: Israel Comment: I use the MASTER-PROG programmer, and if indeed I have done projects with PIC 16F84A and the correction function.
At this point try with usb counter.
As I have echo, informs him of the events.
Thanks for listening.
01.04.2013 - 02:44 Name: Moty Comment: Hi Israel.
The folder ASM contains files for the project written in asm code. Folder C-GPL contains files for the project in C code. The codes are only similar in the way they operate the project. I recommend to use the C-GPL hex file but if you want to modify the code and you use asm code then you have to use the asm hex.
You can try to program the pic to both hex files and see if any of them work. You can also download the code of the USB COUNTER project and try to program the pic with it, don't build the circuit of the USB counter just write the hex and try if the PC recognizes the device. If the PC doesn't recognize any of the 3 hex files then it is likely that the problem is not with the hex.
What pic programmer do you use? have you ever programmed successfully another pic? Make sure your programmer inserts the configuration bits. You can't use bootloader with these hex files.
01.04.2013 - 01:11 Name: Israel Comment: Hi Moty.
Now I have such circuit as in the diagram, I did what you told me and all drivers are okay, do not fail me other than a bookstore?
My PC does not recognize the device when connected and when I do them only 3 LEDs light up with the .hex of the C-GPL folder. I have no idea what could be the error, hope you can help me.
Thank you.
01.04.2013 - 01:11 Name: Israel Comment: Hi Moty.
Now I have such circuit as in the diagram, I did what you told me and all drivers are okay, do not fail me other than a bookstore?
My PC does not recognize the device when connected and when I do them only 3 LEDs light up with the .hex of the C-GPL folder. I have no idea what could be the error, hope you can help me.
Thank you.
31.03.2013 - 23:52 Name: Israel Comment: Ok, I'll check that.
Another question, does the PIC what .hex file should I write, does the ASM folder of the folder or the C-GPL?
thanks
31.03.2013 - 23:47 Name: Israel Comment: Ok, I'll check that.
Another question, does the PIC what .hex file should I write, does the ASM folder of the folder or the C-GPL?
thanks
30.03.2013 - 22:27 Name: Moty
Comment: Hi Israel.
If your PC works OK for USB mouse or keyboard then you already have HID driver. It is normally installed with XP. You can try updating your drivers with this Microsoft download:
http://xpdrivers.com/microsoft/_2_135761.cfm?gclid=CPfXwZeopbYCFW_KtAod6B4AIw
You can also search HP for updated drivers for your model.
Make sure that the connections to the USB are correct and that the crystal is 4MHz. Don't use a bootloader
to program the PIC, most of them require special firmware. Good luck and
don't hesitate to ask more questions.
30.03.2013 - 03:21
Name: Israel
Comment: Hello, since the program began. Hex on my pic but when I connect it to my PC (Win XP Hp), tells me that it does not recognize the device and that I need drivers. Can you tell me what drivers should I watch?, Or what goes wrong?
When connecting the circuit LEDs are lit only pin 21, 22, 24 ..
Please help me ..: S
10.07.2012 - 21:04
Name: Moty
Comment: Hi Abdoalreza, With This project you can connect using USB only.
10.07.2012 - 09:11
Name: Abdoalreza
Comment: Hi
plase for me code port RS232 to PLC send
thank
10.07.2012 - 09:10
Name: Abdoalreza
Comment: Hi
plase for me code port RS232 to PLC send
thank
21.05.2012 - 04:10
Name: Vaibhav Jain
Comment: Dear Sir:
I want to develop USB based applications provided by you.
I have some questions;-
1. Is VB6 runs on Win7.
2. how can I make a graph which show volt vs time
and amp. vs time with recording.
thanks
your truly
vaibhav
18.12.2011 - 18:16
Name: Moty
Comment: Hi Ali, I'm glad to see that it works well.
18.12.2011 - 07:54
Name: ali
Comment: Hi Moty
all inputs (digital and analogue) have problem but outputs work well.
I connected pin 2,3,4,5 to earth and it showed that when one pin(2) connected, other input signal decrease, when 2 pin (2,3)or and other pin connected to earth all inputs signal(digital and analogue with together) become 0 and no signal appear.
thanks
best regard
17.12.2011 - 22:33
Name: Moty
Comment: Hi Ali.
Try running the PIC with pins 2,3,4,5 connected to pin 8 (earth). If you still read analogue outputs then it can be the software. Are the digital inputs and outputs working well?
17.12.2011 - 08:27
Name: ali
Comment: hi moty
sorry
with out connecting any analogue input have signal its my problem.i check earth connection (pin 8 & pin 19)not problem.wire connection is 1 m lenght. i replace 10 uf with 0.47 but i have signal.i dont know i confuse.
may be from pic firmware.?
thank
best regard
11.12.2011 - 18:37
Name: Moty
Comment: Hi Ali,
I assume you mean that the analogue output readings aren't stable. Try to connect the analogue inputs of the PIC to earth and if the readings are stable then check your signals for noise. Try to use short USB lead. Try to increase the 0.47 capacitor to 10uF, that will remove noise from the 5V supply.
11.12.2011 - 06:57
Name: ali
Comment: hi moty
i assembled and test, it worked,but have very noise ,not constant. what problem or things maybe caused.
thanks
best regard
09.05.2011 - 08:32
Name: Moty
Comment: Hi Ali,
The files p18xxx.h etc are in the system of MPLAB and mcc18 programs. You need those 2 programs to be able to compile the hex file. I attached them to the email in case that you wish to use a different compiler.
08.05.2011 - 04:20
Name: ali
Comment: hi
in zip file i can not find p18xxx.h,stdio.h and usart.h .please,how can i get these
thank
09.07.2010 - 22:13
Name: Eduardo Ramos & Fernando Mendoza
Comment: Hey, congratulations This is a great job,I was thinking the same, but you did it, can you send me the c code?
eduardoramogaz@hotmail.com --> Eduardo' mail
v771v771@hotmail.com --> Fernando's mail
we would like to make like a router so with this we can cotroll the device