AnsweredHot!PIC18F2431 , who can help me to make it work

Page: < 123 Showing page 3 of 3
Author
gkuijpers@telkomsa.net
Starting Member
  • Total Posts : 63
  • Reward points : 0
  • Joined: 2015/09/16 10:03:22
  • Location: 0
  • Status: offline
Re: PIC18F2431 , who can help me to make it work 2015/11/04 02:38:57 (permalink)
0 (1)
Thank you Harry, Actual it was some 40 years ago when I did the first assembler program for the 4 bit Siemens processor. But Harry, I am not a professional like you and did no courses, nor work day in day out with assembler. My apology, you youngsters are all more experienced  than me, but you have helped me greatly. Thanks Bert
post edited by gkuijpers@telkomsa.net - 2015/11/11 09:08:12
#41
ric
Super Member
  • Total Posts : 22101
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: offline
Re: PIC18F2431 , who can help me to make it work 2015/11/04 05:07:52 (permalink)
+1 (1)
The only place that "12" appears is in the address bus into the RAM.
The address bus into the FLASH/ROM has 21 bits.
The data coming out of the FLASH/ROM is 16 bits wide. That is the width of one instruction, and that is the width used by Microchip to classify the "core".

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#42
gkuijpers@telkomsa.net
Starting Member
  • Total Posts : 63
  • Reward points : 0
  • Joined: 2015/09/16 10:03:22
  • Location: 0
  • Status: offline
Re: PIC18F2431 , who can help me to make it work 2015/11/04 06:46:00 (permalink)
0
Thank you, One is never too old to learn. I did appreciate your explanation. Bert
post edited by gkuijpers@telkomsa.net - 2016/08/23 11:12:23
#43
gkuijpers@telkomsa.net
Starting Member
  • Total Posts : 63
  • Reward points : 0
  • Joined: 2015/09/16 10:03:22
  • Location: 0
  • Status: offline
Re: PIC18F2431 , who can help me to make it work 2015/11/08 00:51:09 (permalink)
0
Hi Dario,
 
I have 2 more questions.
a)      Do I have to lock the protection bits? I don’t mind if my work gets copied. However, maybe there are other reasons for locking, like protection against voltage spikes or variations.
b)      Is there a faster way to multiply the 10 bit ADC reading by 4. Reason is, I measure my current over a 1 milliOhm resistance and one 10 bit is 4.8818 milliVolt or 4.8 Ampere, while my 8 bit correction (addwf) is 19,3 ampere or 19.36 millivolt. By multiplying I create the same condition but need it, if possible faster. I am running at 20 MHz.
The ADC reading on 3 pins sequential in the same command works like a dream. Bert
This is how I have done it.
1)                              movf     ADRESH,w           ; get ADC result
2)                              movwf  TEMP2
3)                              addwf   TEMP2
4)                              movf     TEMP2,w
5)                              addwf   TEMP2
6)                              addlw   B'00011100'   ; add 50 steps to 2 x 103 steps
7)                              btfsc      STATUS,0      ; if borrow bit is set > stop motor 
8)                              goto       overcrntloop
9)                              bcf          STATUS,0
Many thanks
Bert
#44
ric
Super Member
  • Total Posts : 22101
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: offline
Re: PIC18F2431 , who can help me to make it work 2015/11/08 01:01:06 (permalink) ☄ Helpfulby gkuijpers@telkomsa.net 2015/11/10 06:20:42
+3 (2)
gkuijpers@telkomsa.net
a)      Do I have to lock the protection bits? I don’t mind if my work gets copied. However, maybe there are other reasons for locking, like protection against voltage spikes or variations.

No. They are only for copy protection. They won't provide any other protection.
 

b)      Is there a faster way to multiply the 10 bit ADC reading by 4.

How exactly are you doing it now?
The compiler will do a multiply by four by simple shifting left twice, so that will be pretty quick.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#45
gkuijpers@telkomsa.net
Starting Member
  • Total Posts : 63
  • Reward points : 0
  • Joined: 2015/09/16 10:03:22
  • Location: 0
  • Status: offline
Re: PIC18F2431 , who can help me to make it work 2015/11/08 02:05:52 (permalink)
0 (1)
Thank you Ric, Locking: That put my mind to ease. I can now place it in my boat and make changes whenever I want.
Thanks for the solution for shifting to get a multiplex of 4. I did it much to complex. Thanks I will change my work. Bert
 
#46
gkuijpers@telkomsa.net
Starting Member
  • Total Posts : 63
  • Reward points : 0
  • Joined: 2015/09/16 10:03:22
  • Location: 0
  • Status: offline
Re: PIC18F2431 , who can help me to make it work 2015/11/09 09:32:42 (permalink)
0
Hi Ric.
Ric, I am going banana's . The motor runs beautiful, I am getting information from the 4 buffer registers by sequential FiFO reading of AN0, AN1 and AN2, 
However I have no means to verify the contents of the info reading from those ADC input pins. Can I trust it?
With the below program. I have no experience whether it is correctly written.
 
Many thanks for all the help you have given me.  I was also multiplying it by 4, but I think, that by writing the ADRESH to w, it automatically will be multiplied by 4, because of justification. Therefore I made a mistake and I had a result of 16x 
 
If you glance at the the content of my program do you see anything what is very wrong?
Initialize
                                clrf          DrivePort             ; all drivers off
                                 banksel      TRISA
                                clrf          DrivePortTris      ; set motor drivers as outputs
                                movlw  B'00000111'         ; A/D on RA0, RA1, RA2
                                movwf  TRISA
                                movlw  b'00001111'         ; motorsensors on RB,<2:0>
                                movwf  TRISB
                                bcf          LED2                      ; ensure overheating is reset
                                bcf          LED3                      ; ensure overcurrent is reset
                                bcf          BUZZER                                ; ensure buzzer is switched off
                                movlw  B'11000000'
                                movwf  T0CON                  ; timer0 = on ; timer0 = 8bit 1;2
                                clrf          TEMP1
                                clrf          TEMP2
                                clrf          TEMP3
                                clrf          TEMP4
                                clrf          LastSensor          ; initialize last sensor reading
                                call           Commutate      ; determine present motor position
                                clrf           ADC                     ; start speed control threshold at zero until first ADC
                                bsf          LED1                      ; display program running
                                call          SetAN0
Loop
                                call          ReadADC
                                etc
                                etc the rest of the program for the Brushless motor
                                goto        Loop
                               
 
SetAN0
                                movlw  B'00000000'  ; old = '00100001'
                                movwf  ADCON2
                                movlw  B'00101001' ;left justified,  8 TAD, FOSC/8
                                movwf  ADCON3
                                movlw  B'00000000'
                                movwf  ADCHS
                                movlw  B'00000111' ; >>>>>>>changed from 4 to 3
                                movwf  ANSEL0                 ; ensure AN0,1,2 ADC input is analogue
                                movlw  B'00010101' ;  >>>>>>>>>>bit 6 from 1 to 0         
                                movwf  ADCON0
                                bsf     ADCON0,GO   ; start ADC 
                                return
ReadADC
;                               btfsc      ADCON0, NOT_DONE  ; is ADC ready?
;                               return   ; No, not ready -  return
;                               bsf         ADCON0,GO      ; start the analogue to digital converter 
;                               btfsc      GO_DONE,1       ; check whether A/D properly has read
;                               goto    $-1
                                Btfsc     ADCON0, DONE
                                bra        ReadADC
                                movlw  B'00010000'
                                movwf  ADCON1             
                                movf     ADRESH,w           ; get ADC result
                                movwf  ADC,                    ; save result in speed control threshold
                                movwf  TEMP1
                                movlw  B'00010001'
                                movwf  ADCON1             
                                movf     ADRESH,w           ; get ADC result
                                movwf  TEMP2
                                movlw  B'00010010'
                                movwf  ADCON1             
                                movf     ADRESH,w           ; get ADC result
                                movwf  TEMP3
                                movlw  B'00010011'
                                movwf  ADCON1             
                                movf     ADRESH,w           ; get ADC result
                                movwf    TEMP4
                                bcf         STATUS,0
                                movf     TEMP2,w
                                addlw    B'00000000'   ; add xyz steps to the steps >>>>>>>>>>>
                                btfsc      STATUS,0      ; if borrow bit is set > stop motor 
                                goto       overcrntloop
                                bcf         STATUS,0
                                movf     TEMP3,w
                                addlw    B'00000000' ; if borrow bit is set > stop motor >>>>>>>>>>>
                                btfsc      STATUS,0             ; if nil, do another loop
                                goto       overhtngloop
                                bcf          STATUS,0
                                bsf          ADCON0,GO      ; restart ADC
                                return
 
#47
gkuijpers@telkomsa.net
Starting Member
  • Total Posts : 63
  • Reward points : 0
  • Joined: 2015/09/16 10:03:22
  • Location: 0
  • Status: offline
Re: PIC18F2431 , who can help me to make it work 2016/08/09 10:12:51 (permalink)
0
It is now a year ago that I was successful in solving y problems with the PIC18F2431. Thank you all who have helped me.  XXXXXXXXXXXXXXXXXXXXX False Alarm, I solved it after 3 days. The -$ does not allow to read the ADC. Sooooooooooooorrrrrrrrrrrryyyyyyyyyyyy
However I unfortunately I destroyed a few during sailing and saltwater.
I have ordered new ones from Microchip Direct, which will be here only next week.
 
I made a test board with the PIC12F675 to test my heavy current settings and my overheating settings. I do something wrong. The ADC does not read the value at the input.
I swapped AN1 and AN0 >>>>> no luck, both does not read any input value
It has to do something with the settings in declaring the registers. BUT WHAT.
Everything else is working in the program, flashing, LED's output etc. just the ADC's don't read the input value.
 
Here is the important part of the program (the program itself is running fine, it just does not read the ADC inputs, whatever I have changed and tried. Unfortunately PIC12F675 does not support the "bra" instruction, which have learned to appreciate.
 
WHAT IS MISSING OR WHAT IS WRONG ??????
PIC 12F675 SDIP
;   pin 1 is VDD  + 5 Volt
#define reading1 gpio,0  ; input current pin 7
#define reading2 gpio,1  ; input temperature pin 6
#define LED1  gpio,2 ; Red warning led to 270 Ohm pin
#define CUTOUT  gpio,4 ; 270 Ohm, switching MCLR to low PIC16F887A/1937 pin 3
#define LED2    gpio,5 ; Blue LED pin 2
;   pin 8 is VSS (ground)
;   gpio,3  ; pin 4 is MCLR

 org 0x000
  nop      ; required for ADC
 goto init
 org 10h                        ; startup vector
init
 bsf........... status,rp0    ; bank1
 movlw...... b'11111111' ; osc at maximum
 movwf osccal             
 movlw...... b'00000011' ; trisio  register AN0, AN1 (pin cpio0) = input cpio 2-5 = output
 movwf...... trisio
 movlw...... b'00110011' ; set internal osc A/D from PIC12F675 >>>> 
                                    ; pin 2 and 3 set as analogue input AN0, AN1
 movwf...... ansel
 
 movlw.......b'00000000' ; settings for Option register
 movwf...... option_reg                  
 bcf...........  status,rp0     ; bank0
 movlw.....   b'00000011'  ; settings for Input output. AN0 = input  all other pins = output
 movwf....... gpio
 clrf........... gpio               ;  Init GPI0
 bcf............ gpio,4           ;  switch CUTOUT off  
 bcf ........... LED1             ;  switch Red led off
 bcf ............LED2             ;  switch blue led off
Loop
 call........... ReadADC
 nop x 16
 call.........    ReadADC2
 nop x 16
 goto .......   Loop
  
ReadADC
 movlw .......B'10000001'  
 movwf ...... adcon0
 bsf ........... adcon0,go    ; start the analogue to digital converter 
 btfsc........  go_done,1    ; check whether A/D properly has read
 goto........   $-1 XXXXXXXXXXXXXXXXXXXXX False Alarm, I solved it after 3 days. The -$ does not allow to read the ADC. Sooooooooooooorrrrrrrrrrrryyyyyyyyyyyy
 movfw.....   adresl,w       ; get ADC result
 addlw........ B'11001001' ; add 201 steps (Hex C9) to the steps for 60 Ampere
 btfsc......... status,0        ; if borrow bit is set > stop motor 
 goto......... overcrntloop
 bcf........... status,0
 return
 
ReadADC2
 movlw...... B'10000101'  
 movwf...... adcon0
 bsf........... adcon0,go  ; start the analogue to digital converter 
 btfsc........ go_done,1  ; check whether A/D properly has read
 goto.........$-1XXXXXXXXXXXXXXXXXXXXX False Alarm, I solved it after 3 days. The -$ does not allow to read the ADC. Sooooooooooooorrrrrrrrrrrryyyyyyyyyyyy
 movf........ adresl,w     ; get ADC result
 bcf .......... status,0
 addlw....... 0xE3.......   ; add 227 to the reading if <Hex FF = OK if >Hex 1.00 ; stop motor
 btfss........ status,0
 goto........  overhtngloop
 return
 
Any suggestion is appreciated.
Bert
post edited by gkuijpers@telkomsa.net - 2016/08/10 14:07:37
#48
gkuijpers@telkomsa.net
Starting Member
  • Total Posts : 63
  • Reward points : 0
  • Joined: 2015/09/16 10:03:22
  • Location: 0
  • Status: offline
Re: PIC18F2431 , who can help me to make it work 2016/08/23 11:35:04 (permalink)
0
I have ordered new ones from Microchip Direct, which will be here only next week.   >>> >>>>> I received them last week and made the PIC18F2431 working beautiful. HOWEVER !!!!!
 
Folks, it must have happened to you also. Unaware that this could happen to me, the configuration bits was set by me on the ICD2LE  (my ICD3 packed up last week for no reason) i.e. not in the code, but I selected this in the window >> Configure >>Configuration bits >> HS oscillator  etc etc.  I did removed the tick from the little window: Configuration bits set in code
To my horror the PIC18F2431 was programmed with rubbish and code protected.  I sadly lost now 4 IC's and had 2 IC's from last batch also with a similar problem.
 
HERE IS MY QUESTION> Did I loose now a few hundred dollars in shipping, clearing and purchase costs OR IS THERE A WAY TO ERASE EVERYTHING AND STILL BE ABLE TO USE THOSE BRAND NEW IC's ??? Without that it erases the identification information loaded during manufacturing.
 
I searched all posts, but could not find a similar question and answer.
 >>>>
Now you could really help me and will be grateful to you.
Bert
 
#49
gkuijpers@telkomsa.net
Starting Member
  • Total Posts : 63
  • Reward points : 0
  • Joined: 2015/09/16 10:03:22
  • Location: 0
  • Status: offline
Re: PIC18F2431 , who can help me to make it work 2016/08/23 11:35:09 (permalink)
0
I have ordered new ones from Microchip Direct, which will be here only next week.   >>> >>>>> I received them last week and made the PIC18F2431 working beautiful. HOWEVER !!!!!
 
Folks, it must have happened to you also. Unaware that this could happen to me, the configuration bits was set by me on the ICD2LE  (my ICD3 packed up last week for no reason) i.e. not in the code, but I selected this in the window >> Configure >>Configuration bits >> HS oscillator  etc etc.  I did removed the tick from the little window: Configuration bits set in code
To my horror the PIC18F2431 was programmed with rubbish and code protected.  I sadly lost now 4 IC's and had 2 IC's from last batch also with a similar problem.
 
HERE IS MY QUESTION> Did I loose now a few hundred dollars in shipping, clearing and purchase costs OR IS THERE A WAY TO ERASE EVERYTHING AND STILL BE ABLE TO USE THOSE BRAND NEW IC's ??? Without that it erases the identification information loaded during manufacturing.
 
I searched all posts, but could not find a similar question and answer.
 >>>>
Now you could really help me and will be grateful to you.
Bert
 
#50
gkuijpers@telkomsa.net
Starting Member
  • Total Posts : 63
  • Reward points : 0
  • Joined: 2015/09/16 10:03:22
  • Location: 0
  • Status: offline
Re: PIC18F2431 , who can help me to make it work 2017/11/14 01:28:14 (permalink)
0
Folks I have a problem. It is some years later.  My PIC18F2431 works beautiful, my motors run beautiful on them,. However I dont know how to create a new thread for a problem I have. 
My MPLAB ICD 3 packed up  thus I am forced to use my ICD2LE 
I have lots of PIC16F877A programmed and they work properly.
However I have 2 which have the following problem.
1) Error ICD 0161 - verify failed Memory type = program address = 0x5 Expected value 0x1706 value read 0x1440  programing failed. 
2) error ICD warning Invalid target device ID expected=071 ,  read 0x0 
running ICD self test = passed
ICD 2 ready for next operation.
3) another IC works and program properly thus it is not the ICD2LE what is faulty or not  connected
 
I suspect the new IC's have a problem I purchased last year or I must have done something wrong with them, do you know how to fix them. the first one is a memory problem, the second one is probably an internal failure.
Any help is greatly appreciated, as I have to pay pennies to Microchip for the cost of the product, bu have to pay a fortune to the importers/clearing agent.
Any comment greatly appreciated.
Please also guide me how to place a new thread should I have another programming problem.
Thanks Bert   
  
 
post edited by gkuijpers@telkomsa.net - 2017/11/14 01:49:46
#51
qhb
Superb Member
  • Total Posts : 6258
  • Reward points : 0
  • Joined: 2016/06/05 14:55:32
  • Location: One step ahead...
  • Status: offline
Re: PIC18F2431 , who can help me to make it work 2017/11/14 01:35:45 (permalink)
0
Before getting too concerned, try putting a pull-down resistor on the RB3/PGM pin of the PIC, and see if that helps.
 
#52
gkuijpers@telkomsa.net
Starting Member
  • Total Posts : 63
  • Reward points : 0
  • Joined: 2015/09/16 10:03:22
  • Location: 0
  • Status: offline
Re: PIC18F2431 , who can help me to make it work 2017/11/14 03:22:05 (permalink)
0
No luck, I think I have to throw them in the rubbish bin. Sad for me.Bert
#53
gkuijpers@telkomsa.net
Starting Member
  • Total Posts : 63
  • Reward points : 0
  • Joined: 2015/09/16 10:03:22
  • Location: 0
  • Status: offline
Re: PIC18F2431 , who can help me to make it work 2017/11/14 22:15:48 (permalink)
0
qhb
 
Re: PIC18F2431 , who can help me to make it work  Actual it is the PIC16F877A who gave the problems. The PIC18 is working fine
 
Before getting too concerned, try putting a pull-down resistor on the RB3/PGM pin of the PIC, and see if that helps. 
 
Thanks for the reply. Sadly, it did not work for both faulty IC's. I can't find the original post whereupon you respond. My apology that i try to make it a private post. It did not work.  I will have to throw them in the rubbish bin. Sad, but that is life. 
Thanks so much for the reply. Bert (gkuijpers@telkomsa.net) Sorry I am 77, thus things are a little more difficult for me. 
#54
gkuijpers@telkomsa.net
Starting Member
  • Total Posts : 63
  • Reward points : 0
  • Joined: 2015/09/16 10:03:22
  • Location: 0
  • Status: offline
Re: PIC18F2431 , who can help me to make it work 2017/11/16 12:39:44 (permalink)
0
Hi qhb, I have tried at various ways to give you kind answer a reply. None apparently worked out. It is actual 2 x PIC16F887A which is giving me hardship. Thank you, unfortunately it did not work and still the IC is not programmable anymore. You see the problem is that the cost of the IC is low, but our customs and clearing declarations make it about 40 dollar each IC. No I am very happy with my PIC18F2431, all of them work now like a dream.  I may have to throw those 2 in the rubbish bin. Sadly. Bert
#55
Page: < 123 Showing page 3 of 3
Jump to:
© 2018 APG vNext Commercial Version 4.5