[SOLVED !] data from laptop into pic


Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Thread: data from laptop into pic2071 days old

  1. #1
    lemans
    Guest lemans's Avatar

    0 Not allowed!

    Default data from laptop into pic

    dear all,

    is it possible to send a data set of approx 25 variables from a laptop- (using USB) into a pic (16F648)

    I've developped a digital ignition which is working fine, this is however a fixed ignition curve unit. I can program the curve but during the trip I cannot alter it without special programming equipment. perhaps the video is familiar.

    http://s1233.photobucket.com/user/le....mp4.html?o=49


    as the ignition curve is a function of approx 25 variables, is it possible to send a data set from a ordinary laptop to the pic. other users can then setup their own ignition curve.

    I.ve searched the web, found lots of information but what is the easyest way to proceed.

    regards Anne

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    Prolific Poster hadv215's Avatar
    Join Date
    Sep 2009
    Posts
    1,136
    Thumbs Up
    Received: 66
    Given: 26
    Total Downloaded
    3.61 GB

    0 Not allowed!

    Default Re: data from laptop into pic

    The 16F648 does not have a USB module, so that will be pretty hard to achieve.
    You could use a USB<>TTL converter and connect that to the Rx pin

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    lemans
    Guest lemans's Avatar

    0 Not allowed!

    Default Re: data from laptop into pic

    thank you hadv215,
    in the data sheet is a USART module mentioned, RB1 and RB2 are Rx and Tx respectively.
    with the 5V of the usb connector to an unused pin, say RB0 you can inform the pic about the connection via USB to PC

    (if pin RB0 = high then the USB is connected to PC so change to subprogram data transfer; end if)

    but then?
    the PC has to send data in a specific format, what formats can I choose and how do I proceed?
    the PIC has to recieve data, how to store this data in the eprom memory?

    regards Anne

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #4
    Prolific Poster hadv215's Avatar
    Join Date
    Sep 2009
    Posts
    1,136
    Thumbs Up
    Received: 66
    Given: 26
    Total Downloaded
    3.61 GB

    0 Not allowed!

    Default Re: data from laptop into pic

    You're welcome.

    I mentioned a USB <> TTL converter. This means a piece of hardware containing a chip that is able to translate the USB signals to TTL signals and vice versa.
    See the photo below, on the right side there's a USB connector, on the left side is a header with pins to connect to the Rx and Tx pins of the PIC

    Click image for larger version

Name:	DSCF0895.JPG
Views:	4
Size:	77.0 KB
ID:	2280

    If you're not familiar with this concept, do some googling on FTDI232. That is a pretty famous solution for this kind of problems.

    Regarding the data format, you can choose any kind of format you please as long as both the PC and the PIC know how to deal with them.
    Storing in EEProm is easy, just read the manual, it's all explained there.

    Regards,

    Harm

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  9. #5
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,352
    Thumbs Up
    Received: 83
    Given: 183
    Total Downloaded
    5.30 GB

    0 Not allowed!

    Default Re: data from laptop into pic

    @lemans USB is a complex, multilevel protocol and although it is possible to use a general purpose PIC, for practically no extra cost you can get a PIC with a hardware USB engine built-in.

    George

  10. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  11. #6
    Prolific Poster hadv215's Avatar
    Join Date
    Sep 2009
    Posts
    1,136
    Thumbs Up
    Received: 66
    Given: 26
    Total Downloaded
    3.61 GB

    0 Not allowed!

    Default Re: data from laptop into pic

    But there would still be the need for a host application to provide the data... (of course there are at least two decent USB HID monitors available on this site...)

    Regards
    Harm

  12. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  13. #7
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,352
    Thumbs Up
    Received: 83
    Given: 183
    Total Downloaded
    5.30 GB

    0 Not allowed!

    Default Re: data from laptop into pic

    Just to add to hadv215's remarks, obviously you still need software on the PIC (which runs along side your application) to use the USB engine.

    George

  14. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  15. #8
    lemans
    Guest lemans's Avatar

    0 Not allowed!

    Default Re: data from laptop into pic

    thanks all,

    I've bought this one off Ebay

    http://www.ebay.com/itm/FT232RL-FTDI...item20ecc74546

    and will see if I can get started.
    Yes I need an application in the PIC which only runs when loading data
    and I need a program in the PC, to send the data from an Excel-application via USB. this part worries me most.

    regards Anne

  16. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  17. #9
    Prolific Poster hadv215's Avatar
    Join Date
    Sep 2009
    Posts
    1,136
    Thumbs Up
    Received: 66
    Given: 26
    Total Downloaded
    3.61 GB

    0 Not allowed!

    Default Re: data from laptop into pic

    Hi Anne,

    The converter you show should indeed be a suitable type.

    An application in the PIC always runs when it is powered on, not only when it is loading data.
    Though your PIC application may of course 'do nothing' when it is not receiving data.
    It sounds very unlikely to me, why would a PIC only receive data and do nothing with it?????

    Sending data from the PC isn't that hard. Just find yourself a decent terminal program that can send files over and you're halfway there.
    The built-in serial monitor in the IDE will not do because it can't load files to transmit.
    Save the Excel data to a suitable ascii format like csv, load in the terminal and send it over.
    Write the program for the pic to 'understand' the csv file.
    Just make sure the PIC is big enough to receive the data. But you said it was 25 values, so that should not lead to problems.

    Things to remember:
    - PC and PIC must run at the same baudrate
    - number of data bytes, stop bits etcetera should be the same, just use the defaults, you can't miss

    Regards
    Harm

  18. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  19. #10
    lemans
    Guest lemans's Avatar

    0 Not allowed!

    Default Re: data from laptop into pic

    I should express myself more clearly

    the program for loading data will only run when the USB is connected, thus/yhen loading data and storing in the eprom

    the ohter program will use the eprom data but only if the usb is not attached.

    one application, two program parts.

    regards Anne

  20. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  21. #11
    lemans
    Guest lemans's Avatar

    0 Not allowed!

    Default Re: data from laptop into pic

    hi and best wishes for the new year.

    I'm trying to start communications between laptop and pic 16f628.
    laptop -> USB ->ftdi232 -> 16f628.

    I'm able to send data from rhe PIC tp the laptop using hyperterminal. the data is presented.

    now I'm trying to send data from teh laptop to the pic, no results.
    I've tried several codes, this is the last one used (to no avail)

    [code]
    '************************************************* ***************
    '* Name : UNTITLED.BAS *
    '* Author : xxxx *
    '* Notice : Copyright (c) 2014 cccc *
    '* : All Rights Reserved *
    '* Date : 28-12-2014 *
    '* Version : 1.0 *
    '* Notes : *
    '* : *
    '************************************************* ***************


    ;================================================= ===============================================
    DEVICE 16F628 ;Gebruik een 16F628 type
    CONFIG WDT_OFF, PWRTE_ON, LVP_OFF, MCLRE_OFF, HS_OSC ; de config
    XTAL 20 ;Kristal van 20 MHz
    ALL_DIGITAL TRUE ;Alle ingangen digitaal

    CLEAR

    DECLARE HSERIAL_BAUD 9600 'set baudrate op 9600
    ; 76543210
    DECLARE HSERIAL_RCSTA = 010000 ' Enable serial port and continuous receive
    DECLARE HSERIAL_TXSTA = 100000 ' Enable transmit and asynchronous mode
    DECLARE HSERIAL_CLEAR = ON ' reset buffer bij een overflow?
    DECLARE LCD_RSPIN = PORTA.3 ;RS = pin 4 LCD
    DECLARE LCD_ENPIN = PORTA.0 ;EN = pin 6 LCD



    ;In/Uitgangen instellen
    ; 76543210
    PORTA = 000000 ;1 = 5V 0 = 0V
    PORTB = 000000 ;1 = 5V 0 = 0V
    TRISA = 110000 ;1 = input 0 = output
    TRISB = 000000 ;1 = input 0 = output

    SYMBOL led_1 = PORTA.1
    SYMBOL led_2 = PORTA.2

    DIM waarde AS BYTE ' zet de grote van waarde als een byte
    DIM out AS BYTE

    led_1 = 0
    led_2 = 0
    out = 0

    start: 'hoofdprogramma
    CLS

    INTCON.7 = 1
    INTCON.6 = 1
    PIE1.5 = 1
    ON_INTERRUPT GOTO int
    GOTO main

    int:
    CONTEXT SAVE
    led_1 = 1
    HSERIN [waarde]
    PRINT AT 1,1, waarde
    DELAYMS 300
    led_1 = 0
    CONTEXT RESTORE
    GOTO start

    main:

    TOGGLE led_2
    DELAYMS 200
    'out = out + 1
    'hrsout out
    GOTO start
    END
    /[uncode]

    can someone help me out
    regards A
    Last edited by lemans; 2nd January 2015 at 22:03.

  22. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  23. #12
    Prolific Poster RGV250's Avatar
    Join Date
    Aug 2005
    Posts
    2,363
    Thumbs Up
    Received: 29
    Given: 7
    Total Downloaded
    1.16 GB

    0 Not allowed!

    Default Re: data from laptop into pic

    Hi Anne,
    This might help to get you going, I often use hyperterminal to make simple changes while debugging and one key options IE below if I enter N,n / M,m or A,a i can run different parts of the code.
    I do not use interrupts for any of this, this might help to at least prove you can get communications both ways.

    I just have a variable at the start of the program for the input buffer.
    Dim IN_CHR As Byte ' Character in input buffer

    In my main loop have the serial in (the first lines in the main loop)
    HSerIn 1,Timeout,[IN_CHR] 'Check for input, allow 1ms, if nothing recieved continue (goto Timeout)
    Timeout:

    and then the conditions to test for.
    If IN_CHR = "N" Or IN_CHR = "n" Then GoSub SET_NODE_MASK
    If IN_CHR = "M" Or IN_CHR = "m" Then GoSub SET_MESSAGE_MASK
    If IN_CHR = "A" Or IN_CHR = "a" Then GoSub SET_ALL

    and at the end of the subroutines clear the buffer
    IN_CHR = 0 'clear the input buffer

    Regards,
    Bob
    Last edited by RGV250; 2nd January 2015 at 22:25.

  24. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  25. #13
    Prolific Poster hadv215's Avatar
    Join Date
    Sep 2009
    Posts
    1,136
    Thumbs Up
    Received: 66
    Given: 26
    Total Downloaded
    3.61 GB

    0 Not allowed!

    Default Re: data from laptop into pic

    The fact you see nothing may have a number of reasons:
    - the baudrates are not the same
    - the connection between the converter and the PIC is incorrect
    - the connection between the PIC and the LCD is incorrect or different from the defaults PDS uses (you don't have any declares for your LCD)

    There is another reason and that is that you display a byte value.
    Let me assure you that if you receive a byte containing "00000000" Print at will probably not show anything because an LCD displays the ASCII representation of the byte sent to it. So to see a "0" the value 48 must be received by the Pic and sent to the LCD.
    If your program sends a byte containing "123" the LCD will display a "{". So make sure your PC program sends values that have ASCII representations.
    To show "123" the PC program should send 49, 50, 51.

    A number of remarks:

    You use HSerIn in an interrupt handler, that is not necessarily the best way to do it.
    If there is an interrupt and RCIF is set to 1 you can read the value from the RXREG register.
    Code:
    Symbol RCIF = PIR1.5
    ...
    Context Save
    if RCIF = 1 then
      toggle led_1
      waarde = RXREG
      Print at 1,1, dec waarde
    endif
    Context Restore
    Having a delay inside an interrupt handler, especially one so big, is really bad programming. Interrupt handlers should be as fast as possible.
    The reason for this is that during the delay anything may happen and your program just does not react because the uC will not handle any interrupts until the Context Restore is executed. That's why I took out the delay and changed led_1 = 1 to toggle led_1.
    A better way is to use a semaphore, eg like this
    Code:
    dim bReceived as bit
    In the interrupt handler[code]
    if RCIF = 1
    bReceived = 1[code]
    in main:
    Code:
    if bReceived = 1 then
    print at 1,1, dec waarde ; display the numerical value of the byte received
    bReceived = 0
    delayms xxx ; where xxx depends on the speed the bytes are coming in
     endif
    Putting CLEAR in front of the Dim statements will not clear these variables.
    GoTo Start after Context Restore is meaningless, the code will never be executed.
    GoTo Start in 'main:' is a sign of sloppy programming, a better way would be to do something like this:
    Code:
    main:
    while (1=1)
    Toggle led_2
    Delayms 200
    Cls
    wend
    One more remark: from the comments in your program I see you followed the famous PicBasic.nl course.
    Although commenting a program is always a good thing, there certainly is something like useless comment...and you have a lot of it.
    All of your comment up to the line "out = 0" can be left out and nobody will notice because it does not add a thing to the understanding of the program.
    Now where you should have added comment is with PIR1.5 because nobody is expected to know these exact bits by heart.
    It would even be better to do this
    Code:
    Symbol RCIE = PIE1.5
    Symbol RCIF = PIR1.5
    after the Dim statements and next
    Code:
    RCIE = 1
    The funny thing is that almost everybody knows the meaning of INTCON bits 7 and 6 so they hardly need comment, though adding the Symbols GIE and PEIE is good practice.
    Last edited by hadv215; 2nd January 2015 at 22:42.

  26. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  27. #14
    lemans
    Guest lemans's Avatar

    0 Not allowed!

    Default Re: data from laptop into pic

    HADV215 and RGV250, Thank you for your lengthy answers, especially so late at night.

    started all over again and the defining trick is in the datasheet; RTFM.

    Follow these steps when setting up an Asynchronous
    Reception:
    1. TRISB<1> bit needs to be set and TRISB<2> bit
    cleared in order to configure pins RB2/TX/CK
    and RB1/RX/DT as the Universal Synchronous
    Asynchronous Receiver Transmitter pins.
    setting trisb<1> makes all the difference.
    I wonder why I haven't seen this in any code before, all the other programmers do not bother with setting these registers at all.
    lo it works, now I can proceed to the next hurdle, excell.

    regards Anne
    Last edited by lemans; 3rd January 2015 at 13:15.

  28. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  29. #15
    Prolific Poster RGV250's Avatar
    Join Date
    Aug 2005
    Posts
    2,363
    Thumbs Up
    Received: 29
    Given: 7
    Total Downloaded
    1.16 GB

    0 Not allowed!

    Default Re: data from laptop into pic

    Hi,
    I have never used them but it might be that I use different deeclares.
    Hserial_RCSTA = %10010000 ' Enable serial port and continuous receive
    Hserial_TXSTA = %00100100 ' Enable transmit and asynchronous mode

    Bob

  30. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. pic to sms data
    By Roshan in forum GSM / SMS
    Replies: 6
    Last Post: 6th October 2009, 16:45
  2. Adapting IBM Laptop LCD to PIC
    By normnet in forum The Lounge
    Replies: 5
    Last Post: 4th May 2008, 09:46
  3. [SOLVED !] Multi-PIC data clash
    By bravo in forum Proton Plus Compiler v3
    Replies: 4
    Last Post: 3rd January 2006, 20:42
  4. Pic to Pic data using bluetooth
    By Roshan in forum quickBlue Bluetooth Development
    Replies: 4
    Last Post: 7th December 2005, 21:19
  5. [SOLVED !] Serial data between 1 master pic & 8 slave pic
    By Roshan in forum Proton Plus Compiler v3
    Replies: 2
    Last Post: 23rd September 2005, 11:21

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts