Saturday 8 December 2012

PIC24FJ64GB002 - USB Host Board

Finally got the prototype board and PIC24FJ64GB002. This is how it looks like.

Top Side

Bottom side
Close up on the PIC24FJ64GB002
The whole unit with TPLink MA180 Connected.



The RS232 level shifter is not mounted since it is connected to the USB/Serial module based on ftdi rs232 which was designed earlier.

A quick check with a modified firmware to change the UART pin connection. Some configuration register setting is not usable (example USB 96Mhz) and it was giving a compile error. So it was removed. The compiled hex file was flash into this new board.

With a teraterm console open to monitor and UART activity, power up the unit and keep my finger cross.

Voila, there was life. The unit power up and start to output messages...

þªR(&M£J256GB106 Device Initialized
3G USB Application Initialize
No USB Device Connected
3GD: Try to install driver on DeviceID 2357 ProductID f006
3GD: Not supported Device & Product ID
Switching to 3G Modem on DevID = 2357 ProductID = 0200
Detaching Device
3GD: Try to install driver on DeviceID 2357 ProductID f006
3GD: Not supported Device & Product ID
3GD: Try to install driver on DeviceID 2357 ProductID 0201
TPLink MA180 Connected
TPLink MA180 Ready
ati
Manufacturer: TP-LINK INCORPORATED
Model: MA180
Revision: M6290A-KPRZL-2.4.0240T  1  [Jan 17 2011 10:00:00]
IMEI: 8630770ccccxxxxx
+GCAP: +CGSM,+DS,+ES
OK
Seems the software written earlier on the PIC24FJ256GB106 could somehow work on the PIC24FJ64GB002. However some problem was detected in the earlier booting. There is some corrupt data from debug log when power up.

The corrupted debug log was resolved. This was due to some buffer that wasn't being initialized upon boot up.

The configuration register was examine and modified from GB106 to GB002. This conclude this post. The next post will examine into the AT command parser to send and receive SMS.

After one long year has passed, Decide the continue this work a little further. Finally added a simple AT command parser to do the following task.

1. Set SMS to Text Mode
2. Set SMS to Sim-Card Storage
3. Get the list of message.
4. Read message and parse the command.
5. Delete the Read Message.
6. Check if Reply Request was made.

The system will turn on/off LED by using OnButtonX and OffButtonX, The PIC will reply Button1 to 4 Status if a SMS with Reply is send.


 

Wednesday 14 November 2012

Prototype 3G USB Model to Serial Converter


Background of this project

The main purpose of this project is to control an embedded system using GSM SMS system. In Malaysia the GSM Modem <-> Serial is rather costly for experimenting. However there are many used 3G USB modem which is available in "ebay" and "lelong.com.my".

So out came this idea to use a USB modem instead of a costly specific Serial Inteface GSM modem.

The first Scale Down Prototype


After successfully working on the starter kit (PIC24FJ256GB106), it is time to make the real prototype using a much smaller size PIC.

This week is long holidays in Malaysia. After this week, will place an order to Farnell Malaysia to purchase the PIC24FJ64GB002 to make this prototype.



Monday 12 November 2012

First Test Log with active SIM CARD.

Today manage to pop in someone's simcard into the TP-Link MA180. Can't use the one I have since they are of MicroSim form factor.


With the valid SIM card, do a quick TEXT SMS send and receive, the test log from PIC24FJ256 is as below. So far I could send and receive SMS using TPLINK MA180 on PIC24FJ256.

Below is the link on this demo software compiled for the starter kit.

https://xp-dev.com/svn/MyJowen/USBGSM/PIC24FJ_StarterKit/USBGSM.hex

The starter kit is modified to connect to PC using UART interface on Pin49-TX (RP24) and Pin33-RX(RP16). Serial Setting is 8Bit, No parity, 1 stop bit, 115200 baud rate.

Success!!! I wonder if I could get the network interface to work to send data through internet using data plan.

3G USB Application Initialize
No USB Device Connected
Unsupported Device DevID = 0000 ProductID = 12DA
Switching to 3G Modem on DevID = 2357 ProductID = 0200
Detaching Device
Unsupported Device DevID = 00FA ProductID = 1396
TPLink MA180 Connected
atz
OK
at+cpin="0123"
ERROR
at+cmgl="ALL"
ERROR
at+cmgf=1
OK
at+cmee=1
OK
at+cmgl="ALL"
+CMGL: 0,"REC READ","10010",,"12/02/29,16:21:39+32"
5C0A656C76845BA26237FF0C60A8672C6B214E0A7F516D4191CF0030002E00340039004D0042FF0C60A85957991051856D4191CF5DF24F7F7528003700300033002E00310038004D0042FF0C52694F596D4191CF0032003300360038002E00380032004D00423002
+CMGL: 1,"REC READ","10010",,"12/03/01,10:24:21+32"
6E2999A863D0793AFF0C622A6B620030003267080032003965E5FF0C60A85F5367085957991051856D4191CF5DF24F7F7528003100360039002E00300034004D0042FF0C52694F596D4191CF0032003300360038002E00380032004D00423002767B5F558054901A7F514E0A84254E1A5385007700770077002E00310030003000310030002E
+CMGL: 2,"REC READ","10010",,"12/03/01,10:24:21+32"
0063006F006DFF0C67E58BE230014EA48D3930015145503C300165B94FBF53C85B9E60E00021

OK
at+cpms="SM"
+CPMS: 0,50,3,23,3,23

OK
at+cmgl="ALL"
OK
at+cpms=?
+CPMS: ("ME","MT","SM","SR"),("ME","MT","SM","SR"),("ME","MT","SM","SR")

OK
at+cpms="SM","SM","SM"
+CPMS: 0,50,0,50,0,50

OK
at+cmgl="ALL"
OK
at+cmgl="ALL"
+CMGL: 0,"REC UNREAD","+6016xxxxxx",,"12/11/12,21:33:09+32"
Test again  
<- First Message Received
OK
at+cmgl="ALL"
+CMGL: 0,"REC READ","+6016xxxx",,"12/11/12,21:33:09+32"
Test again
<- Second Message Received
OK
at+cmgl="ALL"
+CMGL: 0,"REC READ","+6016xxx6",,"12/11/12,21:33:09+32"
Test again
+CMGL: 1,"REC UNREAD","+60163xxxx6",,"12/11/12,21:34:04+32"
Test one more time

OK
at+csmp=17,167,0,16
OK
at+cmgs="+601xxxxxx"
> This is my test to your reply
<- Try to send a SMS 
+CMGS: 30
OK <- Send Successfully!!!
No USB Device Connected

Getting TPLink MA180 to work on PIC24FJ256GB106

For this project will use the Microchip USB host driver. To get it to work, need to create new driver to first switch to USB modem mode, setup the endpoints to transfer the AT command to the endpoints.





 
Try to send some AT commands.
 
 
 
 
so far so good!
 
Next will pop in a valid SIM Card and check if I could send and receive SMS using PIC24FJ256GB106 with a TP Link MA180 USB 3G Modem.


Probing TPLink MA180 in Modem Mode

After installing the windows driver, the 3G USB modem appear and install on COM12 on my Win7 machine




Examine the report from USB Viewer shows a total of 12 endpoints.  After examine the data log when using the modem, it is found the USB modem is installed on interface number 3 as highlighted below in BLUE
Device Descriptor:
bcdUSB:             0x0200
bDeviceClass:         0x00
bDeviceSubClass:      0x00
bDeviceProtocol:      0x00
bMaxPacketSize0:      0x40 (64)
idVendor:           0x2357
idProduct:          0x0201
bcdDevice:          0x0000
iManufacturer:        0x03
0x0409: "TP-LINK, Incorporated"
iProduct:             0x02
0x0409: "TP-LINK HSUPA Modem"
iSerialNumber:        0x04
0x0409: "@@@@@@@@@@"
bNumConfigurations:   0x01
ConnectionStatus: DeviceConnected
Current Config Value: 0x01
Device Bus Speed:     High
Device Address:       0x02
Open Pipes:             12
Endpoint Descriptor:
bEndpointAddress:     0x81  IN
Transfer Type:        Bulk
wMaxPacketSize:     0x0200 (512)
bInterval:            0x20
Endpoint Descriptor:
bEndpointAddress:     0x01  OUT
Transfer Type:        Bulk
wMaxPacketSize:     0x0200 (512)
bInterval:            0x20
Endpoint Descriptor:
bEndpointAddress:     0x82  IN
Transfer Type:        Bulk
wMaxPacketSize:     0x0200 (512)
bInterval:            0x20
Endpoint Descriptor:
bEndpointAddress:     0x02  OUT
Transfer Type:        Bulk
wMaxPacketSize:     0x0200 (512)
bInterval:            0x20
Endpoint Descriptor:
bEndpointAddress:     0x84  IN
Transfer Type:   Interrupt
wMaxPacketSize:     0x0040 (64)
bInterval:            0x05
Endpoint Descriptor:
bEndpointAddress:     0x85  IN
Transfer Type:        Bulk
wMaxPacketSize:     0x0200 (512)
bInterval:            0x20
Endpoint Descriptor:
bEndpointAddress:     0x04  OUT
Transfer Type:        Bulk
wMaxPacketSize:     0x0200 (512)
bInterval:            0x20
Endpoint Descriptor:
bEndpointAddress:     0x86  IN
Transfer Type:   Interrupt
wMaxPacketSize:     0x0040 (64)
bInterval:            0x05
Endpoint Descriptor:
bEndpointAddress:     0x87  IN
Transfer Type:        Bulk
wMaxPacketSize:     0x0200 (512)
bInterval:            0x20
Endpoint Descriptor:
bEndpointAddress:     0x05  OUT
Transfer Type:        Bulk
wMaxPacketSize:     0x0200 (512)
bInterval:            0x20
Endpoint Descriptor:
bEndpointAddress:     0x03  OUT
Transfer Type:        Bulk
wMaxPacketSize:     0x0200 (512)
bInterval:            0x00
Endpoint Descriptor:
bEndpointAddress:     0x83  IN
Transfer Type:        Bulk
wMaxPacketSize:     0x0200 (512)
bInterval:            0x00
Configuration Descriptor:
wTotalLength:       0x008A
bNumInterfaces:       0x05
bConfigurationValue:  0x01
iConfiguration:       0x01
0x0409: "TP-LINK Configuration"
bmAttributes:         0xE0 (Bus Powered Self Powered Remote Wakeup)
MaxPower:             0xFA (500 Ma)
Interface Descriptor:
bInterfaceNumber:     0x00
bAlternateSetting:    0x00
bNumEndpoints:        0x02
bInterfaceClass:      0xFF
bInterfaceSubClass:   0xFF
bInterfaceProtocol:   0xFF
iInterface:           0x00
Endpoint Descriptor:
bEndpointAddress:     0x81  IN
Transfer Type:        Bulk
wMaxPacketSize:     0x0200 (512)
bInterval:            0x20
Endpoint Descriptor:
bEndpointAddress:     0x01  OUT
Transfer Type:        Bulk
wMaxPacketSize:     0x0200 (512)
bInterval:            0x20
Interface Descriptor:
bInterfaceNumber:     0x01
bAlternateSetting:    0x00
bNumEndpoints:        0x02
bInterfaceClass:      0xFF
bInterfaceSubClass:   0xFF
bInterfaceProtocol:   0xFF
iInterface:           0x00
Endpoint Descriptor:
bEndpointAddress:     0x82  IN
Transfer Type:        Bulk
wMaxPacketSize:     0x0200 (512)
bInterval:            0x20
Endpoint Descriptor:
bEndpointAddress:     0x02  OUT
Transfer Type:        Bulk
wMaxPacketSize:     0x0200 (512)
bInterval:            0x20
Interface Descriptor:
bInterfaceNumber:     0x02
bAlternateSetting:    0x00
bNumEndpoints:        0x02
bInterfaceClass:      0x08
bInterfaceSubClass:   0x06
bInterfaceProtocol:   0x50
iInterface:           0x00
Endpoint Descriptor:
bEndpointAddress:     0x03  OUT
Transfer Type:        Bulk
wMaxPacketSize:     0x0200 (512)
bInterval:            0x00
Endpoint Descriptor:
bEndpointAddress:     0x83  IN
Transfer Type:        Bulk
wMaxPacketSize:     0x0200 (512)
bInterval:            0x00
Interface Descriptor:
bInterfaceNumber:     0x03
bAlternateSetting:    0x00
bNumEndpoints:        0x03
bInterfaceClass:      0xFF
bInterfaceSubClass:   0xFF
bInterfaceProtocol:   0xFF
iInterface:           0x00
Endpoint Descriptor:
bEndpointAddress:     0x84  IN
Transfer Type:   Interrupt
wMaxPacketSize:     0x0040 (64)
bInterval:            0x05
Endpoint Descriptor:
bEndpointAddress:     0x85  IN
Transfer Type:        Bulk
wMaxPacketSize:     0x0200 (512)
bInterval:            0x20
Endpoint Descriptor:
bEndpointAddress:     0x04  OUT
Transfer Type:        Bulk
wMaxPacketSize:     0x0200 (512)
bInterval:            0x20
Interface Descriptor:
bInterfaceNumber:     0x04
bAlternateSetting:    0x00
bNumEndpoints:        0x03
bInterfaceClass:      0xFF
bInterfaceSubClass:   0xFF
bInterfaceProtocol:   0xFF
iInterface:           0x00
Endpoint Descriptor:
bEndpointAddress:     0x86  IN
Transfer Type:   Interrupt
wMaxPacketSize:     0x0040 (64)
bInterval:            0x05
Endpoint Descriptor:
bEndpointAddress:     0x87  IN
Transfer Type:        Bulk
wMaxPacketSize:     0x0200 (512)
bInterval:            0x20
Endpoint Descriptor:
bEndpointAddress:     0x05  OUT
Transfer Type:        Bulk
wMaxPacketSize:     0x0200 (512)
bInterval:            0x20
With these information, it is ready to get it to work on PIC24FJ256GB106.


Probing TP_Link MA180

Plug in the TP-Link MA180 into Win7 PC. The mass storage driver was loaded and it creates 1 CD Emulation and 1 SD-Micro drive.

The first stage of the device is having below identification

idVendor: 0x2357
idProduct: 0x0200
bcdDevice: 0x0000


and uses 2 endpoints with below attributes

bEndpointAddress: 0x01 OUT
Transfer Type: Bulk
wMaxPacketSize: 0x0200 (512)
bInterval: 0x00

Endpoint Descriptor:
bEndpointAddress: 0x81 IN
Transfer Type: Bulk
wMaxPacketSize: 0x0200 (512)


At this stage, there is nothing about 3G USB modem. So this unit requires some switching to 3G USB modem mode. Next will install the driver the comes with the unit as a CD emulation drive.

The probe results from USB Viewer...

Device Descriptor:
bcdUSB:             0x0200
bDeviceClass:         0x00
bDeviceSubClass:      0x00
bDeviceProtocol:      0x00
bMaxPacketSize0:      0x40 (64)
idVendor:           0x2357
idProduct:          0x0200
bcdDevice:          0x0000
iManufacturer:        0x03
0x0409: "TP-LINK, Incorporated"
iProduct:             0x02
0x0409: "TP-LINK HSUPA Modem"
iSerialNumber:        0x04
0x0409: "Deleted IMEI Number"
bNumConfigurations:   0x01
ConnectionStatus: DeviceConnected
Current Config Value: 0x01
Device Bus Speed:     High
Device Address:       0x02
Open Pipes:              2
Endpoint Descriptor:
bEndpointAddress:     0x01  OUT
Transfer Type:        Bulk
wMaxPacketSize:     0x0200 (512)
bInterval:            0x00
Endpoint Descriptor:
bEndpointAddress:     0x81  IN
Transfer Type:        Bulk
wMaxPacketSize:     0x0200 (512)
bInterval:            0x00
Configuration Descriptor:
wTotalLength:       0x0020
bNumInterfaces:       0x01
bConfigurationValue:  0x01
iConfiguration:       0x01
0x0409: "TP-LINK Configuration"
bmAttributes:         0xC0 (Bus Powered Self Powered )
MaxPower:             0xFA (500 Ma)
Interface Descriptor:
bInterfaceNumber:     0x00
bAlternateSetting:    0x00
bNumEndpoints:        0x02
bInterfaceClass:      0x08
bInterfaceSubClass:   0x06
bInterfaceProtocol:   0x50
iInterface:           0x00
Endpoint Descriptor:
bEndpointAddress:     0x01  OUT
Transfer Type:        Bulk
wMaxPacketSize:     0x0200 (512)
bInterval:            0x00
Endpoint Descriptor:
bEndpointAddress:     0x81  IN
Transfer Type:        Bulk
wMaxPacketSize:     0x0200 (512)
bInterval:            0x00

Sunday 11 November 2012

USB 3G Modem on PIC24FJ256GB106 Starter Kit

Ok....Now I have a blog, so what to blog....


TP Link MA180 3.75G HSUPA Modem is right infront of me now, so might as well blog this thing. Last week bought this modem with intention to connect to Microchip PIC24F256GB106 starter kit.

Will use the blog to record every single development of this project for future references.

 
 
Hopefully I can get it to work when they are connected like this....
 
 
Now I am all ready, software is next on my development list...