Announcement

Collapse
No announcement yet.

ulcd70dt and uart

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • cardan
    replied
    this is my code and works perfectly on a pic16f628 via a 43ptc display


    here is the code program on 4mhz and hs fuses



    DEFINE OSC 4 '4 MHz crystal snelheid
    INCLUDE "modedefs.bas" ' Include mode
    CMCON=7

    LED VAR PORTB.5 ' led op poort b.1
    Reset var PORTB.4
    displayout var PORTB.0 ' tx port van pic
    displayin VAR PORTB.1 ' rx port van pic
    controleled VAR BYTE [$6] 'Receive de controle byte van 4dsystems
    LOW RESET 'reset pin op scherm laag voor reset
    PAUSE 40 'tijd voor reset
    HIGH RESET 'continue hoog op reset pin
    led = 0 'led op uit

    pause 3500 ' tijd voor cls en programma opstart

    DEFINE I2C_SCLOUT 1

    ' ** DÉFINITION DES ENTREES - SORTIES

    ' Sorties I2C
    SCL var PORTB.2 ' SCL sur RB1 (pin 7)
    SDA var PORTB.3 ' SDA sur RB0 (pin 6)

    'Boutons
    MEMO var PORTA.2 ' Bouton de mémorisation sur RA2 (pin 1)
    UP var PORTA.0 'augmente la fréquence (sur RA0)
    DOWN var PORTA.1 'diminue la fréquence (sur RA1)

    INPUT UP 'Up et Down sont des entrées
    INPUT DOWN
    INPUT MEMO


    ' ** DÉCLARATION DES VARIABLES
    checkf2 var byte
    checkf3 var byte
    checkmeter1 var byte
    b1 var BYTE
    b2 var BYTE
    b3 var BYTE
    b5 var BYTE

    F1 var WORD
    F2 var WORD
    F3 var WORD
    msbf2 var word
    lsbf2 var word
    msbf3 var word
    lsbf3 var word
    msbmeter1 var word
    lsbmeter1 var word
    ADDR1 VAR BYTE
    TMP VAR WORD
    TMP_LO VAR TMP.LOWBYTE
    TMP_HI VAR TMP.HIGHBYTE
    PLLBASE VAR WORD
    PLL VAR WORD
    LO VAR PLL.LOWBYTE
    HI VAR PLL.HIGHBYTE
    PAS VAR BYTE '1=125kHz, 2=250kHz, 4=500kHz, 8=1MHz

    '*** DONNEES INITIALES ***

    ADDR1=$C2 'adresse I2C du SDA5055
    PLLBASE=9920 'début à 2200 MHz : 2200 / 0,125 = 17600
    PAS = 4 ' pas de 125 kHz par défaut

    EEPROM 0,[$90,$01]


    '
    '*** LECTURE DU DECALAGE TMP ***

    READ 0,TMP_LO 'lit les 8 bits de poids faible
    READ 1,TMP_HI 'lit les 8 bits de poids fort


    ' *** DÉBUT DU PROGRAMME ***



    MAIN:

    PLL = PLLBASE + TMP
    I2CWRITE SDA,SCL,ADDR1,[HI,LO,$8E]

    GOSUB CALCUL
    GOSUB AFFICHAGE



    '*** BOUCLE PRINCIPALE ***

    BOUCLE:

    checkf2 =$01^$0f^$00^msbf2^lsbf2 'checksum for f2 status
    msbf2 = f2.highBYTE
    lsbf2 = f2.LOWBYTE

    serout2 displayout ,84, [$01,$0f,$00, msbf2,lsbf2,checkf2]
    SERIN2 displayin,84,[controleled] 'serial in voor opvraag controle byte
    if controleled = $6 then
    high led 'aan van led

    low led 'led bij portb.5
    endif
    checkf3 =$01^$0f^$02^msbf3^lsbf3
    msbf3 = f3.highbyte
    lsbf3 = f3.lowbyte
    serout2 displayout ,84, [$01,$0f,$02, msbf3,lsbf3,checkf3]
    SERIN2 displayin,84,[controleled] 'serial in voor opvraag controle byte
    if controleled = $6 then
    high led 'aan van led

    low led 'led bij portb.5
    endif


    BUTTON UP,0,0,0,b1,1,MONTE
    BUTTON DOWN,0,0,0,b2,1,DESCEND
    BUTTON MEMO,0,1,0,b5,1,STORE

    GOTO BOUCLE


    MONTE: '** AUGMENTE LA FRÉQUENCE DE 1 PAS

    TMP = TMP + PAS
    IF TMP > 2000 THEN TMP = 0
    GOTO MAIN

    DESCEND: '** DIMINUE LA FREQUENCE DE 1 PAS

    IF TMP<PAS THEN RAZ_TMP
    IF TMP = 0 THEN TOP
    TMP = TMP - PAS
    GOTO MAIN

    TOP: TMP = 0

    RAZ_TMP: TMP = 2000 '600
    GOTO MAIN

    CHOIX: '** CHOIX DU PAS

    IF PAS = 8 THEN SAUTE
    PAS = PAS*2
    GOSUB AFFICHE_PAS
    GOSUB AFFICHAGE
    GOTO BOUCLE

    SAUTE:
    PAS = 8
    GOSUB AFFICHE_PAS
    GOTO BOUCLE

    CALCUL: ' ** CALCUL DE LA FREQUENCE

    F1= PLL - 8000
    F2=F1/8 'donne les MHz
    F3=125*(F1//8)/100 'donne les kHz
    RETURN

    AFFICHAGE:







    serout2 displayout ,84, [$01,$0f,$01,$00,$01,$0E]
    SERIN2 displayin,84,[controleled] 'serial in voor opvraag controle byte
    if controleled = $6 then
    high led 'aan van led

    low led 'led bij portb.5
    endif


    serout2 displayout ,84, [$01,$0f,$00, msbf2,lsbf2,checkf2]
    SERIN2 displayin,84,[controleled] 'serial in voor opvraag controle byte
    if controleled = $6 then
    high led 'aan van led

    low led 'led bij portb.5
    endif
    checkf3 =$01^$0f^$02^msbf3^lsbf3
    msbf3 = f3.highbyte
    lsbf3 = f3.lowbyte
    serout2 displayout ,84, [$01,$0f,$02, msbf3,lsbf3,checkf3]
    SERIN2 displayin,84,[controleled] 'serial in voor opvraag controle byte
    if controleled = $6 then
    high led 'aan van led

    low led 'led bij portb.5
    endif
    RETURN

    AFFICHE_PAS:

    RETURN

    '*** MEMORISATION DE LA FRÉQUENCE

    STORE:
    WRITE 0, TMP_LO 'Stocke les 8 bits de poids faible de TMP dans l'EEPROM à l'adresse 0
    WRITE 1, TMP_HI 'Stocke les 8 bits de poids fort de TMP dans l'EEPROM à l'adresse 1
    serout2 displayout ,84, [$01,$13,$00,$00,$01,$13]
    SERIN2 displayin,84,[controleled] 'serial in voor opvraag controle byte
    if controleled = $6 then
    high led 'aan van led

    low led 'led bij portb.5
    endif
    pause 2000
    serout2 displayout ,84, [$01,$13,$00,$00,$00,$12]
    SERIN2 displayin,84,[controleled] 'serial in voor opvraag controle byte
    if controleled = $6 then
    high led 'aan van led

    low led 'led bij portb.5
    endif
    GOTO BOUCLE


    Leave a comment:


  • cardan
    replied
    yes yes yes yes yes its works fine make a little code to display a valeu from a orginal picbasic code its read en write frequentie on a orginal lcd now i was looking how< tp calculate a checsum and also make lsb en msb so this night my pic works verry fine and now i can write all code to of for my ulcd yes yes yes yes

    Leave a comment:


  • cardan
    replied
    ok mark i wait if there is somebody ho helps me if i can fix it then i write it to alll the digit or knobs or so wath buth the arduino code is for me ???? looking for to convert the script to basic buth pffffffffffff hihihihihiihihi

    Leave a comment:


  • ESPsupport
    replied
    It should not be that hard, I think someone posted a basic example here, just cant find it at the moment.

    There is a discussion here but no actual basic code http://forum.4dsystems.com.au/forum/...g-proton-basic.

    I'm sure it can be done, I just don't have basic available to be at the moment

    Leave a comment:


  • cardan
    replied
    Hello All here friends


    after weeks looking my display works fine if a send a data to the lcd if i do a checksum with the 6 (i write a little test progr in basic and i see the leds comming up if the statement is ok

    so now my first question here ) i'm not a c++ member i have a little code that send to a normal display and works also fine the variables are F2 and F3

    so now i will write in picbasic a little code to split the lsb and lsb also checksum from my pic to the ulcd buth my problem are i don't understood not the c++ what must i do for the correct methode

    help me pls thanks a lotssssssss for answer here the code in picbasic to display the value in decimal on a normal lcd like 20*2 characters this is for me not problem just i have no idee how to write it for a ulcd with checsum or make the string corectly for transfer via the com port


    LCDOUT $FE, 1
    first line print to lcd (normal not a ulcd)


    ' LCDOUT #5 'set a 5 to the display
    ' LCDOUT DEC3 F2 'set the variable F2 to lcd with 3 digits
    ' LCDOUT "." 'set a point to the display
    ' LCDOUT DEC3 F3 'set the variable F3 to lcd with 3 digits

    so if a will send a leddigit value i use and works fine like this serout2 displayout , 84 , [$01,$0f,$00,$02,$3f,$33] so the next is serout2 displayout , 84 , [$01,$0f,$00,F2,F3,CHECSUM]

    ho helps me plssssssss

    Leave a comment:


  • ESPsupport
    replied
    Run GTX against your project and update some values using that. That should give you a feel for what you need to do.

    Also look at the Genie user guide and reference manual about how to build the checksum.

    Then you will need to cut some basic code to split words in two ( using shift and and, assuming that is the keyword in your particular basic) and xor to generate the checksum

    Leave a comment:


  • cardan
    replied
    so now my little basic progr runs verry fine the host is a 16f877a and the ulcd70dt




    DEFINE OSC 4 '4 MHz crystal snelheid
    INCLUDE "modedefs.bas" ' Include mode
    ADCON1 = 15 ' zet PORT A en PORT E digitaal
    TRISB.5 = 0 'zet portb tot 5 op output
    LED VAR PORTB.1 ' led op poort b.1
    Reset var PORTB.0
    displayout var PORTC.6 ' tx port van pic
    displayin VAR PORTC.7 ' rx port van pic
    controleled VAR BYTE [$6] 'Receive de controle byte van 4dsystems
    LOW RESET 'reset pin op scherm laag voor reset
    PAUSE 20 'tijd voor reset
    HIGH RESET 'continue hoog op reset pin
    LED = 0 'led op uit
    pause 2300 ' tijd voor cls en programma opstart
    MAIN: 'hoofdprogramma
    serout2 displayout , 84 ,[$04,$06,$02]
    'serout2 displayout , 84 ,[$01,$0f,$00,$00,$01,$0f]
    serout2 displayout , 84 ,[$01,$13,$00,$00,$01,$13] 'led 0 aan
    pause 500
    serout2 displayout , 84 ,[$01,$13,$01,$00,$01,$12] ' led 1 aan
    pause 500
    serout2 displayout , 84 ,[$01,$13,$02,$00,$01,$11] 'led 2 aan
    pause 500
    serout2 displayout , 84 ,[$01,$13,$00,$00,$00,$12] 'led 0 uit
    pause 500
    serout2 displayout , 84 ,[$01,$13,$01,$00,$00,$13] 'led 1 uit
    pause 500
    serout2 displayout , 84 ,[$01,$13,$02,$00,$00,$10] ' led 2 uit
    'gosub controlebit 'na 8 instructies ga naar controlebite $6
    ' serout2 displayout , 84 ,[$01,$0f,$00,$00,$01,$0f] 'zet getal 001 op display
    pause 500


    serout2 displayout , 84 ,[$04,$04,$00]


    gosub controlebit

    controlebit:
    SERIN2 displayin,84,[controleled] 'serial in voor opvraag controle byte
    if controleled = $6 then
    high led 'aan van led
    pause 500 'wacht 0/5 sec
    low led 'led bij portb.5
    endif
    pause 1000
    'terug naar main progr
    gosub main









    So Now i will write a variable value in this serout2 statement buth how hi grtz alain

    Leave a comment:


  • ESPsupport
    replied
    Hmm, COM0 is always to the same fixed pins, the pin settings are only applicable to COM1 (as per the title of the area where you change the pins), have you changed the setting to COM1?

    The pin settings show up in the main procedure in the 4dGenisS file, immediately after the '// init comms' comment

    Leave a comment:


  • cardan
    commented on 's reply
    hey marc yes in the part options i set my rx tx pins thanks for that

  • cardan
    replied
    here is a test with slider and leddigit its runs and have look to de rx tx pins now p4 and p5 for comm 0

    #platform "uLCD-70DT"

    // generated 26/12/2014 1:48:00

    #MODE RUNFLASH

    #inherit "4DGL_16bitColours.fnc"

    #inherit "VisualConst.inc"


    #inherit "testpa41GenieConst.inc"


    #constant IPDatasize 22

    #CONST
    CMDLenMAX 80
    #END

    #CONST
    BGIMAGE 0x0020
    ACK 0x06
    NAK 0x15
    ReadCmd 0x80
    WriteCmd 0x00
    // IPD_TYPE 0 // offsets are doubled as FLASH is byte addressable
    IPD_P1 2
    IPD_P2 4
    IPD_P3 6
    IPD_P4 8
    IPD_P5 10
    IPD_P6 12
    IPD_P7 14
    IPD_DOWN 16
    IPD_RELEASE 18
    IPD_OBJVidx 20
    // object indexes
    tDipSwitch 0
    tKnob 1
    tRockerSwitch 2
    tRotarySwitch 3
    tGSlider 4
    tTrackbar 5
    tWinButton 6
    tAngularmeter 7 // need to implement use of this, inputs must be ordered first
    tCoolgauge 8
    tCustomdigits 9
    tForm 10
    tGauge 11
    tImage 12
    tKeyboard 13 // this is a special input, does not need to be at front
    tLed 14
    tLeddigits 15
    tMeter 16
    tStrings 17 // also need output strings code
    // tStringUNI 0x3f | 0x40
    // tStringANSII 0x3f
    tThermometer 18
    tUserled 19
    tVideo 20
    tStaticText 21
    // Remove, check for non visual objects instead
    // MaxVisObjects 21 // objects that have a visual component
    tSounds 22
    tTimer 23
    tSpectrum 24
    tScope 25
    tTank 26
    tUserImages 27
    tPinOutput 28
    tPinInput 29
    t4Dbutton 30 // more inputs
    tAniButton 31
    tColorPicker 32
    tUserButton 33
    // tGradient, tBorder, tScale are not real objects, generated totally within Workshop
    MaxTotObjects 33 // objects in objects array
    // OT_DISPLAY 22
    OT_REPORT 100
    OT_SETCONST 101
    OT_SETANOTHER 102
    OT_ACTIVATE 103
    OT_NEXTFRAME 104
    OT_PREVFRAME 105
    OT_NEXTSTRING 106
    OT_PREVSTRING 107
    // other OT_s Form activate,
    // Indexes into LedDigits and CustomDigits arrays
    ileft 0
    iDigits 2
    iMinDigits 4
    iWidthDigit 6
    iLeadingBlanks 8
    // indexes to Strings arrays
    STStartH 0
    STStartL 2
    STSize 4
    STx1 6
    STy1 8
    STx2 10
    STy2 12
    STFGColor 14
    STBGColor 16
    STFontAttribs 18
    STTransparent 20 // bit transparent should 'refresh' background, otherwise rectangle out
    STAnsi 22 // bit defines write/draw routine
    STForm 24 // form this string can be seen in
    // Command codes
    READ_OBJ 0
    WRITE_OBJ 1
    WRITE_STR 2
    WRITE_STRU 3
    WRITE_CONTRAST 4
    REPORT_OBJ 5
    REPORT_EVENT 7
    // End P1.inc
    nObjects 3
    nInputs 2
    ANITIMERS 0
    #END

    #DATA
    word formstidx 0
    word formenidx 3
    word IPControls -1, -1, 0
    word IPData tGSlider, 1, 32, 727, 70, 90, -1, -1, 22, 0, 2,
    OT_SETANOTHER, 15, 0, 0, 16, 0, 0, 0, 0, 0, 0
    word oDipSwitchs 0
    word oKnobs 0
    word oRockerSwitchs 0
    word oRotarySwitchs 0
    word oGSliders 1, iSlider0
    word oTrackbars 0
    word oWinButtons 0
    word oAngularmeters 0
    word oCoolgauges 0
    word oCustomdigitss 0
    word oForms 1, -1
    word oGauges 0
    word oImages 0
    word oKeyboards 0
    word oLeds 0
    word oLeddigitss 1, iLeddigits0
    word oMeters 0
    word oStringss 0
    word oThermometers 0
    word oUserleds 0
    word oVideos 0
    word oStaticTexts 0
    word oSpectrums 0
    word oScopes 0
    word oTanks 0
    word oUserImagess 0
    word oPinInputs 0
    word o4Dbuttons 0
    word oAniButtons 0
    word oColorPickers 0
    word oUserButtons 0
    word oTimers 0
    word oSoundss 0
    word oPinOutputs 0
    word formBGcol 0x0000
    word kKeyboardKeystrokes -1
    word OPDataL 56, 4, 1, 174, 0
    #END

    // Start P2.inc
    var oObjects[MaxTotObjects+1] ; // address of objects
    var curform ;
    var x, y ;
    var inputtype, TState, input, object ;
    var comRX[40], cmd[CMDLenMAX] ;

    var cs, Ocs ;

    func seroutCS(var op)
    serout(op) ;
    Ocs ^= op ;
    endfunc

    func seroutOcs()
    serout(Ocs) ;
    Ocs := 0 ;
    endfunc

    func TMul(var p1, var p2, var p3)
    var var32[2], var322[2] ;
    umul_1616(var32, p1, *(input+p2)) ;
    umul_1616(var322, var32[1], *(input+p3)) ;
    umul_1616(var32, var32[0], *(input+p3)) ;
    return(var32[1] + var322[0]) ;
    endfunc

    func ReadObject(var ObjectType, var ObjectIdx)
    var j, k, Objects ;
    Objects := *(oObjects+ObjectType) ;

    seroutCS(REPORT_OBJ) ;
    seroutCS(ObjectType) ;
    seroutCS(ObjectIdx) ;
    j := 2 + ObjectIdx * 2 + Objects ;
    if (ObjectType == tForm)
    k := curform ;
    else if ((ObjectType == tCustomdigits) || (ObjectType == tLeddigits))
    k := img_GetWord(hndl, *j, IMAGE_TAG2);
    else
    k := img_GetWord(hndl, *j, IMAGE_INDEX);
    endif
    seroutCS(k >> 8) ; // first 8 bits
    seroutCS(k) ;
    seroutOcs() ;
    endfunc


    func WriteObject(var ObjectType, var ObjectIdx, var NewVal)
    var i, j, k, Objects ;
    ObjectType &= 0x3f ;
    if (ObjectType == tForm)
    ActivateForm(ObjectIdx) ;
    else
    Objects := *(oObjects+ObjectType)+ObjectIdx*2+2 ;
    i := *(Objects) ;
    if (ObjectType == tLeddigits)
    img_SetWord(hndl, i , IMAGE_TAG2, NewVal); // where state is 0 to 2
    ledDigitsDisplay(i, oLeddigitss, OPDataL) ;
    else
    img_SetWord(hndl, i , IMAGE_INDEX, NewVal); // where state is 0 to 2
    img_Show(hndl, i) ; // will only display if form is current
    endif
    endif
    endfunc

    Leave a comment:


  • ESPsupport
    replied
    Hmm, I can't quite understand that. Are you perhaps looking for the options on the File, Options, Genie screen?

    Leave a comment:


  • cardan
    replied
    hmmmmmmmmm straings i can not define my serial setting in the genie only in out pins ???

    Leave a comment:


  • cardan
    replied
    wrong code here set tommorow my new test settings
    Last edited by cardan; 26th December 2014, 11:04 AM.

    Leave a comment:


  • rcbandwidth
    replied
    Hello alain: Are you still having a problem or have you made some progress?...If it still is not working post the code you are currently using,this will help a lot.
    Which PIC device are you using?.....

    Leave a comment:


  • cardan
    replied
    pic tx is lcd rx pic rx is lcd tx reset is a litlle time that i have in the begin of the prog with my pic thats alll greetings alain belgium

    Leave a comment:

Working...
X