| Electronics > Beginners |
| Assembly code Help! PIC16F57 |
| << < (14/32) > >> |
| Electrofinn:
Ok just to start, and is probably not relevant to what your asking but I'll get there, below is the values I am now using for "pattern" which is the same pattern as the PIC16C57 I can't access. pattern addwf pc,f retlw 80 retlw 0C0 retlw 0E0 retlw 0F0 retlw 0F8 retlw 0FC retlw 0FE retlw 0FF retlw 7F retlw 0BF retlw 0DF retlw 6F retlw 0B7 retlw 0DB retlw 6D retlw 0B6 retlw 0DB retlw 0ED retlw 0F6 retlw 0FB retlw 0FD retlw 0FE retlw 0FF retlw 0FF retlw 7F retlw 3F retlw 1F retlw 0F retlw 07 retlw 03 retlw 01 retlw 00 I just added a load of 0FF values just for testing at the time because I hadn't yet figured out what the pattern was until recently when you fixed the code for me and was able to run my 32 values. what these values relate to is the 8 yellow leds that are above my segment displays. have attached a picture of the board I am using to test this, this is the old board as it already has the led's soldered in. each value when converted to binary actually corresponds to which leds are lit. so OFF in binary is (11111111) and so all leds are lit or 80 is (10000000) so farthest left led is lit and the rest off ect. when these values run one by one from the top of the list to the bottom, they create a chasing like led pattern. the first 8 values turn the leds on one by one and stay on as they go, the next 16 values does what I call a twinkle pattern and the last 8 is pretty much the reverse of the first 8, they turn off one by one and stay off as they go. the whole thing loops around and looks very pretty and seamless. it does this only when there are no credits and it keeps doing this until you put a credit in, when a credit is inserted the pattern stops and the leds now become a way of knowing how many credits you have, they light up one by one and stay on as each credit is inserted. obviously there are only 8 leds but even if you put more than 8 credits in, the machine still registers them and the leds only start going off one by one when the credits drop below 8. now the segment displays I believe are actually controlled from the lookup table called "table" the first value is 40 which translates to a bar on the display, I know this because I changed this once and made two segment light up instead of one bar. as for the repetition In the "odds" table that always confused me. especially since the lowest value is 08 and in decimal is 8 which is 8 servo actuations... but that's four coins (20p)… this confused me because this is not the lowest prize amount, 10p is the lowest which should be 4 servo actuations. but there is no 04 in that list, so I think that a 10p win is read from somewhere else in the code. please look at this below and go to 6:44 in the vid, you will see briefly the leds doing their thing before he puts a credit in and you'll see the rest of what happens. https://www.youtube.com/watch?v=GCGmK0gCCUI |
| Electrofinn:
here's prize break down |
| KL27x:
--- Quote ---ok just had instance where a win did part of the "pattern" table, --- End quote --- So when you say this, you "won" and "part of the pattern table" happened, do you mean the 8 LEDs lit up in a piece of the "pattern" table? And was it the 8th value in pattern, the way you had changed it? in your revised code that would be 0xFF or all LEDs lit. FYI, in case this state machine is indeed accurate, it can help you figure out the code. The main loop calls all the subroutines in sequence, never-ending. The key to what "state" the program is in is "mode_byte". Depending on what is contained in modebyte, different parts of the Loop become active/inactive. If you wanted to figure out how the program relates to the state machine flow diagram and to the machine, itself, some basic steps would be 1. figure out which bits of modebyte are actually used. This may be done with by throwing the "mode_byte not previously defined" error code. I have already formatted the main loop to tab out the mode_byte checks into their own column. It looks like there may be only 3 or so bits actually used. 2. list all the subroutines which are active in each valid value of mode_byte 3. figure out how that relates to the state machine diagram and/or how the machine is acting. 4. you would also be curious about every place mode_byte is manipulated. Also, if you were serious about fixing this or improving it, probably a good place to start is drawing up a schematic and putting a pin configuration into the code header, just for reference. That said, I'm not saying I'm going to help you fix it, if you did this. But it is an important step. One of the things you may learn to do is to use the outputs already on there to debug. Take the 8 LED bar. You could write up a test loop to output the contents of W or mode_byte or w/e other register you are interested in to this 8 LED bar, and now you see the content wherevever you are inserting that to intentionally break the code. Most people might do that in software, but like I said, I'm low tech. |
| Electrofinn:
yes it ran part of the revised twinkle pattern which would begin on the 9th but it could have started from the 8th but would not of noticed as it would have been too brief. btw I noticed in the list you posted you are calling the first value of 07f ;0, your counting from 0 where as I am counting from 1, to me that's value number 1 lol just saying because we maybe getting our wires crossed. everytime you have given me code i went straight in and put my custom pattern in to make sure that worked first. is that what you wanted to know? or am i not understanding you? |
| Electrofinn:
What I will do is save this topic thread and try my hardest to learn and work through your advice. I hope you don't feel your wasting your time with your superb write up's because if anything else it is extremely interesting and other people will certainly benefit from it, even if I end up failing to wrap my head around it. |
| Navigation |
| Message Index |
| Next page |
| Previous page |