Announcement

Collapse
No announcement yet.

PiTone-v2-by-Eddy71 Has anyone on here built this ?

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

  • Eddy71
    replied
    Originally posted by sbalio1 View Post
    Hi friend David and all friend here i try your hex bat dident works the same error one led is blinking and sound . Problem ?????

    Who am I writing the instructions for in the description on my website?

    "When the microcontroller is turned on, it tests the board parts and calibrates for operation with the parts installed. When the light on the line of LEDs runs from the first to the sixth, the controller tests power stabilization and coil current, when the light moves back, it calibrates for amplifier modes.
    Accordingly, if there is a fault during the first scan (voltage converter, coil, battery, wires), the first LED blinks, if there is a fault in the amplifier (or a spurious op-amp), the second LED will blink."

    Leave a comment:


  • David_1
    replied
    I have spent the evening fighting with the adc, for my sins I do not have 3K3 resistors I use 3K so much I normally see them as the same, obviously in the battery divider and wanting to test Eddys code before I mess it up too much I ended up stacking three 0603 10k resistors in parallel to get closer to 3k3
    Click image for larger version

Name:	building1.jpg
Views:	271
Size:	142.2 KB
ID:	409119
    single res in this pic in red circle

    Leave a comment:


  • waltr
    replied
    Those two PICs are pin for pin compatible. The 16F1824 has more memory and a couple extra features.
    Therefore, the '24 can be used.
    However, you MUST have the Source code and re-complie for the '24.

    Did you use the Code David_1​ created???

    Leave a comment:


  • spartalian
    replied
    hi to all i cant get pic16f1823 just i have pic16f1824 is that a problem to work

    Leave a comment:


  • David_1
    replied
    Click image for larger version

Name:	render.jpg
Views:	282
Size:	139.2 KB
ID:	409074 Click image for larger version

Name:	building.jpg
Views:	283
Size:	150.7 KB
ID:	409075
    what I am hopping for and .............what I have lol

    Leave a comment:


  • David_1
    replied
    Originally posted by sbalio1 View Post
    Hi friend David and all friend here i try your hex bat dident works the same error one led is blinking and sound . Problem ?????
    maybe post a picture of your setup ?

    Leave a comment:


  • sbalio1
    replied
    Hi friend David and all friend here i try your hex bat dident works the same error one led is blinking and sound . Problem ?????

    Leave a comment:


  • David_1
    replied
    pcb's arrived ... am missing a few bits but I think I can build it to try tonight

    Leave a comment:


  • waltr
    replied
    Nearly impossible is not impossible and you will need knowledge of the PIC chip, Assembler and the C it was written in.
    Just not easy to very, very hard to do.

    Thanks for going through your procedure and posting a raw assembler and C code.

    Leave a comment:


  • Carl-NC
    commented on 's reply
    Be quick, you have 30 min after posting.

  • David_1
    replied
    Originally posted by Carl View Post
    Use CODE tags (the '#' button in the editor toolbar), or use Courier font.
    sorry did know we had that here ... is it too late to edit ?

    Leave a comment:


  • Carl-NC
    replied
    Use CODE tags (the '#' button in the editor toolbar), or use Courier font.

    Leave a comment:


  • David_1
    replied
    Originally posted by waltr View Post
    Hex file are nearly impossible to modify.
    You require the Source code to load into MPLAB then built for the correct PIC number.
    not really, been reworking hex files for many years, the trick is do you really want to spend the time, if that answer is yes
    start by setting up MPlabx for the real chip importing the hex, then its possible to export the disassembly into a file.
    At this point its not much use, but you can make choices on what you see, Eddy's code was written in C I Knew this
    but Eddy was kind enough to tell me which "C".. So then I had more than enough to understand the hex, The code I have now will recompile and byte for byte match the original.
    But even that is not so useful I then added many comments, but I still can not test it as my PCB's are stuck Chinese new year, Well they are in transit now yay

    I have a pic here wired to the leds all that code has been tested, I added code to pump out serial rs232.. all in a chip that only had a few words spare, but then its not really the same code...
    here is the start up code well as I see it
    bugger the formatting is lost in the cut and paste.
    sorry for the gibberish but its part of how I keep track of original code.

    Code:
    START ;
    MOVLW 0x57 ;D87 1840 72F 3057
    MOVWF TEMP1 ;0x77 ; 1841 730 00F7
    MOVLW 0x20 ;D32 1842 731 3020
    MOVWF FSR0L ;FSR0L ; 1843 732 84
    MOVLW 0x00 ; 1844 733 3000
    MOVWF FSR0H ;0x5 ; 1845 734 85
    L00Px735 CLRF INDF0 ;CLEAR 87 REG'S ; 0x0 ; 1846 735 180
    INCF FSR0L, F ; 1847 736 0A84
    DECFSZ TEMP1, F ; 1848 737 0BF7
    GOTO L00Px735 ; 1849 738 2F35
    
    CLRF TEMP2 ; 1850 739 01F8
    CLRF TEMP3 ; 1851 73A 01F9
    CLRF TEMP4 ; 1852 73B 01FA
    CLRF 0x7B ;
    CLRF 0x7C ; 1854 73D 01FC
    CLRF 0x7D ; 1855 73E 01FD
    CLRF 0x7E ; 1856 73F 01FE
    ;---------------------------------------------------------------------------------------------------------------------------------------
    MOVLW 0x20 ;CLEAR 32 REG'S 1857 740 3020
    MOVWF TEMP1 ; 1858 741 00F7
    MOVLW 0xA0 ;D160 1859 742 30A0
    MOVWF FSR0L ; 1860 743 84
    MOVLW 0x0 ; 1861 744 3000
    MOVWF FSR0H ; 1862 745 85
    L00Px746 CLRF INDF0 ;CLEAR 32 REG'S 1863 746 180
    INCF FSR0L, F ; 1864 747 0A84
    DECFSZ TEMP1, F ; 1865 748 0BF7
    GOTO L00Px746 ;CLEAR 32 REG'S 1866 749 2F46
    CLRF 0x20 ; 1867 74A 01A0
    ;---------------------------------------------------------------------------------------------------------------------------------------
    ;0111 1 = 16 MHz HF x1x = Internal oscillator bloc
    ;0111 1010
    ; 111 1 = 16 MHz HF
    ; 1x = Internal oscillator bloc
    MOVLW 0x7A ;0111 1010 1868 74B 307A
    MOVLB BANK1 ;0x1;Move literal to BSR 1869 74C 21
    MOVWF OSCCON ;0x19 ; 1870 74D 99
    ;---------------------------------------------------------------------------------------------------------------------------------------
    MOVLB BANK3 ;0x3;Move literal to BSR 1871 74E 23
    CLRF ANSELA ;0xC; 1872 74F 018C
    CLRF ANSELC ;0xE; 1873 750 018E
    MOVLB BANK2 ;0x2;Move literal to BSR 1874 751 22
    CLRF CM1CON1 ;0x12; 1875 752 192
    CLRF CM1CON0 ;0x11; 1876 753 191
    ;?
    CLRF CM2CON1 ;0x14 ; 1877 754 194
    CLRF CM2CON0 ;0x13 ; 1878 755 193
    ;-----------again !
    MOVLW 0x7A ; ; 1879 756 307A
    MOVLB BANK1 ;0x1;Move literal to BSR 1880 757 21
    MOVWF OSCCON ;0x19 ; 1881 758 99
    MOVLW 0x13 ; ; 1882 759 3013
    MOVWF WDTCON ;0x17 ; 1883 75A 97
    MOVLB BANK2 ;0x2;Move literal to BSR 1884 75B 22
    CLRF FVRCON ;0x17 ; 1885 75C 197
    MOVLB BANK1 ;0x1;Move literal to BSR 1886 75D 21
    BCF ADCON1,0 ;00 =VREF+ is connected to AVDD ;0x1E, 0x0; 1887 75E 101E
    BCF ADCON1,1 ;0x1E, 0x1; 1888 75F 109E
    MOVLW Adress0x10 ; 1889 760 3010
    MOVLB BANK3 ;0x3;Move literal to BSR 1890 761 23
    MOVWF ANSELA ;PORTA; 1891 762 008C
    MOVLW 0x00 ; 1892 763 3000
    MOVWF ANSELC ;0xE; 1893 764 008E
    MOVLB BANK1 ;0x1;Move literal to BSR 1894 765 21
    BSF ADCON1,4 ;0x1E, 0x4; 1895 766 161E
    BCF ADCON1,5 ;0x1E, 0x5 ; 1896 767 129E
    BSF ADCON1,6 ;0x1E, 0x6 ; 1897 768 171E
    BCF ADCON1,ADFM ;7 0 = Left justified. Six Least Significant bits of ADRESL ;0x1E, 0x7 ; 1898 769 139E
    BSF ADCON0,ADON ;0 ;0x1D, 0x0 ; 1899 76A 141D
    MOVLW 0x0C ; 1900 76B 300C
    MOVWF TEMP2 ; 1901 76C 00F8
    MOVF ADCON0,W ; 0x1D, W ; 1902 76D 081D
    ANDLW 0x83 ; 1903 76E 3983
    IORWF TEMP2, W ; 1904 76F 478
    MOVWF ADCON0 ;0x1D ; 1905 770 009D
    MOVLW 0x08 ; 1906 771 3008
    MOVLB BANK4 ;Move literal to BSR 1907 772 24
    MOVWF WPUA ; 1908 773 008C
    MOVLB BANK1 ;0x1;Move literal to BSR 1909 774 21
    BCF OPTION_REG,7 ;7 0 = Weak pull-ups are enabled by individual WPUx latch values ;0x15, 0x7 ; 1910 775 1395
    MOVLW 0x01 ; 1911 776 3001
    MOVLB BANK4 ;Move literal to BSR 1912 777 24
    MOVWF WPUC ;0xE; 1913 778 008E
    MOVLB BANK1 ;0x1;Move literal to BSR 1914 779 21
    BCF OPTION_REG,7 ;7 0 = Weak pull-ups are enabled by individual WPUx latch values ;0x15, 0x7; 1915 77A 1395
    MOVLW 0x1F ; 1916 77B 301F
    MOVWF TRISA ; 1917 77C 008C
    MOVLW 0x0F ; 1918 77D 300F
    MOVWF TRISC ;0xE; 1919 77E 008E
    MOVLW 0xF0 ; 1920 77F 30F0
    MOVLB BANK5 ;Move literal to BSR 1921 780 25
    ANDWF CCP1CON,F ;0x13, F; 1922 781 593
    MOVLB BANK2 ;0x2;Move literal to BSR 1923 782 22
    BSF LATA,Coil5 ;TURN ON SPEAKER0xC, 0x5; 1924 783 168C
    BCF LATC,Sounder5 ;TURN OFF SPEAKER0xE, 0x5; 1925 784 128E
    BCF LATC,Motor4 ;TURN OFF SPEAKER0xE, 0x4; 1926 785 120E
    MOVLW 0xC8 ;D200 1927 786 30C8
    MOVLB BANK0 ;0x0;Move literal to BSR 1928 787 20
    MOVWF 0x3C ; 1929 788 00BC
    CALL TEST_T2CON_Z ;L0X3 ; 1930 789 2003
    MOVLW 0x01 ; 1931 78A 3001
    MOVWF 0x3C ; 1932 78B 00BC
    MOVLW 0xF4 ; 1933 78C 30F4
    MOVWF 0x3B ; 1934 78D 00BB
    CLRF 0x3E ; 1935 78E 01BE
    MOVLW 0xC8 ;D200 1936 78F 30C8
    MOVWF 0x3D ; 1937 790 00BD
    CALL L0x2C ; 1938 791 202C
    GOTO L0xE8 ;GO READ COIL! 1939 792 2.80E+09
    
    then with another type of disassembler you can get C'ish code
    
    void main()
    {
    unsigned int batt_voltage;
    unsigned int new_sensitivity, old_sensitivity = 1;
    accumulate_measure_cnt = ACCUMULATE_MEASURE_CNT;
    measurecnt = accumulate_measure_cnt;
    sensitivity_flag = TRUE;
    pulse_flag = FALSE;
    beepdivider = 2048;
    beepcnt = 2048;
    lv_time = LV_TIME_DIVIDER;
    lv_flag = FALSE;
    startup_delay = STARTUP_DELAY;
    cal_cnt = 0;
    pulse_time_reload = PULSE_TIME_DIVIDER;
    pulse_time = pulse_time_reload;
    sensitivity_time = SENSITIVITY_TIME_DIVIDER;
    motion_cal_cnt = 0;
    
    // oscillator
    OSCCON= 0xF0;
    // GPIO init
    // PORT A
    TRISA.TRISA0 = IN; // sensitivity
    PORTA.RA0 = 1;
    TRISA.TRISA1 = IN; // low battery detection
    PORTA.RA1 = 1;
    TRISA.TRISA2 = IN; // motion / non-motion switch
    PORTA.RA2 = 1;
    TRISA.TRISA3 = IN; // pinpoint button
    PORTA.RA3 = 1;
    TRISA.TRISA4 = OUT; // clk out
    PORTA.RA4 = 1;
    TRISA.TRISA5 = IN; // clk in
    PORTA.RA5 = 1;
    
    // PORT C
    TRISC.TRISC0 = OUT; // audio
    PORTC.RC0 = 1;
    TRISC.TRISC1 = IN; // comparator in
    PORTC.RC1 = 1;
    TRISC.TRISC2 = IN; // comparator in
    PORTC.RC2 = 1;
    TRISC.TRISC3 = OUT; // detect out
    PORTC.RC3 = 1;
    TRISC.TRISC4 = OUT; // comparator out
    PORTC.RC4 = 1;
    TRISC.TRISC5 = OUT; // pulse out
    PORTC.RC5 = 1;
    
    // Analog input pins
    ANSELA.ANSA0 = 1; // sensitivity potmeter in
    ANSELA.ANSA1 = 1; // low battery detection
    ANSELC.ANSC1 = 1; // pulse in
    ANSELC.ANSC2 = 1; // pulse in
    
    // timer 1 gating
    T1GCON.TMR1GE = 1;
    T1GCON.T1GPOL = 1; // timer 1 gate active high
    T1GCON.T1GTM = 0;
    T1GCON.T1GSPM = 0;
    T1GCON.T1GSS1 = 1; // comparator 2
    T1GCON.T1GSS0 = 1; // comparator 2
    T1CON.T1CKPS0 = 0;
    T1CON.T1CKPS1 = 0; // timer 1 prescaler = 0
    T1CON.TMR1CS0 = 1; // timer 1 clock = Fosc
    T1CON.TMR1CS1 = 0; // timer 1 clock = Fosc
    T1CON.T1OSCEN = 0; // timer 1 internal oscillator
    T1CON.TMR1ON = 1; // timer 1 active
    TMR1H = 0; // initial timer values
    TMR1L = 0;
    ​​
    ​

    Leave a comment:


  • waltr
    replied
    Hex file are nearly impossible to modify.
    You require the Source code to load into MPLAB then built for the correct PIC number.

    Leave a comment:


  • David_1
    replied
    So I just tried to compile it for the 1824. no clue if it works ? do not have one to try it !
    Attached Files

    Leave a comment:

Working...
X