Many questions mostly about the data/information to be used. This will determine the architecture.
Is the part number a fixed length?
What is the max length of the part number?
What is max price? and what, is it's length?
How many part numbers?
Is any history of transactions required?
How should an invalid part number be handle?
Do you need to list part numbers?
Have you built a solution using ReadTable as a protoype? Was this approach too slow? What is the response expectation in terms of the time from partname entry to return of the price?
What LCD? Why not large GLCD?
This is a very exciting idea. Lots of architecture solutions come to mind. The answers to the questions will really help.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Using a PIC or AVR microcontroller to create a database for your project is definitely possible! Here are some steps and considerations to help you get started:
1.ChoosingtheMicrocontrollerBothPIC,LGTandAVRmicrocontrollersaresuitableforthistask.2.InterfacingwithExternalFlashRAM/USBYou’llneedtointerfaceyourmicrocontrollerwithexternalFlashRAM.ThistypicallyinvolvesusingSPI(SerialPeripheralInterface)orI2C(Inter-IntegratedCircuit)protocols.3.DatabaseManagementFormanagingyourdatabase,youcanuseasimplekey-valuestoreapproach.Herearesomestepstoimplementit:DataStructure:Storeyourpartnumbersandassociateddata(likequantityandtax)inastructuredformat.SearchAlgorithm:Implementabinarysearchorhashtableforfastlookups.Binarysearchisefficientifyourdataissorted,whileahashtablecanprovideconstant-timecomplexityforlookups.4.LibrariesandToolsWhilethereisn’taspecificdatabaselibraryformicrocontrollers,youcanuseexistinglibrariesforhandlingmemoryanddatastructures:5.ExampleCodeSnippetHere’sasimpleexampleofhowyoumightsetupasearchfunction:structurepart_numberaswordquantityasbytetaxaswordItemsdatabase// assume all data as Integers, tax as x100 factored number1001,10,51002,5,20functionsearch_item(part_number)// add binary or hash searchif(item.part_number=part_number)return(x,y,z)else// Return an empty item if not foundreturn(0,0,0.0)part_number=1001;// Example part numberfound_item=search_item(part_number);// Display found_item on LCD6.OptimizationTipsIndexing:Createanindexforyourpartnumberstospeedupsearches.MemoryManagement:Ensureefficientuseofmemorytoavoidfragmentationandoptimizeperformance.
Last edit: Anobium 2024-09-25
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here's the breakdown for the part number records inventory.
(I need your direction on how to get this project to be fast and effective.)
Thank's again for your time and support.
Is the part number a fixed length? yes
What is the max length of the part number? 40 bytes (including all fields)
What is max price? and what, is it's length? 6 digits 9999.99
How many part numbers? 1000 max (fit on 64kb flash RAM)
Is any history of transactions required? yes, for sales reports
How should an invalid part number be handle? return "not found/invalid" if not programmed
Do you need to list part numbers? yes for sales reports
part number description price 6 digits link-dept 2 digits on hand
12 digits 16 characters xxxxxx DD XXXX
part record example: 123456789012abcdefghijklmnopxxxxxxDDXXXX
as for the table read, I did not write any code yet.
2 x serial LCD display (on hand)
LCD 2004 front operator display.
LCD 1602 back display.
timing and operation,
usually between scanning the barcode and displaying the info on the LCD screen
is less than 0.3 sec. (about the same as a regular ECR . )
the thermal receipt to be printed as shown below:
Store name ABC Store
Date / Time 9/12/2024 15:35
Clerk name + number Deby #555
---------------------------
Link Dept Hardware
part number 123456789123
Qty + unit price + ttl 2 @ $ 1.25 $ 2.50
---------------------------
Item Number Item 2
Sales Taxes Tax-1 $ 0.45
Tax-2 $ 0.24
Total Amount due Total $ 3.19 ---------------------------
Paid by Visa $ 3.19
**as for the report of sales: **
Store name ABC Store
Date / Time 9/12/2024 21:35
Clerk name + number Deby #555
---------------------------
Report Mode Z
Dept Hardware
QTY + Part number (2) 123456789012
Price each 2 @ 1.25 2.50
"
Item Number Item 2
---------------------------
Sub Total Sub-Total $ 2.50 Tax 1 Tax-1 $ 0.45
Tax 2 Tax-2 $ 0.24
Total Total $ 3.19
---------------------------
Payment Type Visa $ 3.19
*as for the hardware I'm looking to proceed like this *
I am just replying to other emails. But, I would recommend a USB interface - this can used on a PC for data management etc and the interface should work very well.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I would recommend a basic prototype using table(s)/readtable. This will prove the overall architecture. The storage/USB will need to be tested and resolved but with a hash then you should be able to retrieve the all part data and write the logs etc.
There will be much to do for you. But, start with a prototype using tables, then move to the USB data interface.
Let me think on this in the morning.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Take your time ,I'm not of any rush this project is on my bench for quite some time.
I just ordered 3 x CH376S Chip USB Host Interface modules to Aliexpress.
should be here around Oct 28.
Thank's again for your great support.
So far to work with a 40 K bytes inventory table I have to use an USB Host + Flash drive
or maybe a ( PIC18F27K42T-I/SO with 128 K bytes cost around C$3.90 ) with a main program code under 70 k bytes to generate sales and reports.
when generating a daily report, I can create another internal table.
Let me know if the PIC can work the same.
Also an external file can be used as the table data source, can it be the same to export / save
the table back to a file.
Thank's again for your time.
Last edit: JB 2024-09-26
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here's the diagram let me know if this is ok
offline : loading the ASCII file
online: Scanning, Displaying, Reporting
Also about searching in the table for a record, I add 3 digits (001~999) at the beginning of the part number like in house barcode and use it as a table index to locate in one pass the right record.
Still making some testing with this table index.
1 x RS232 barcode scanner
1 x serial 9600 baud thermal printer
2 x LCD Display serial or I2C I have both on hand
Why I pick a PIC18F27K42
because of Flash Ram of 128kbytes , 64Mhz clock, UART.
My estimation for the main program will never exceed 10 Kbytes + 40 Kbytes inventory + 5 Kbytes report table = 55 Kbytes at the most.
(just retrieving part code, send to display, and print receipt, and generate report .)
if the inventory table need to be adjusted, I can edit on the spot inside the PIC (I guess) or re-load from and existing ASCII file with a USB Host + Flash Drive.
I searched the GBBasic manual about table and didn't found any way to export/save the table.
Is it possible to export/save the table?
Thank's again
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You will need four USARTs. The K42 has two. I would still recommend the 2560.
I was going to ask about data management. I think I get the 40k and the other estimates but what functions are needed with the data?
Assume the parts are sorted in alpha order. You will need a clever lookup routine to ensure the look up does not take a long time. So, assume you add smaller tables to add the search otherwise the search would look up potentially 42 characters before a match happens.
The search could access a table that only has only the first ( say ) six chars. To find a part would be so much faster then once you have the parts that match the 6 chars then search a second table that has a hash for the all 42 chars. The search would only match a hash then you dont have to search 42 chars. But, this means more tables.
These are concepts to get the the results in a meaning time.
I am assuming that all the parts data is actually static in a table. And, you are only writing logs or transactions. You can allocate a DATA block to write to. Exporting would be a read of the DATA block to the USB, and, the same for the TABLE data.
You may want to allocate 1200 parts. Then, you import the parts from the USB to the table. The pre-allocation would be required as the table ( and DATA block) could have program or some other reference data before or after. But, importing the part data to an existing table is doable. When you import you just have following the format of the table structure. Pretty easy.
I still recommend a 2560. Starting with the K42 is ok as the code will be portable to another chip later.
as for the lookup search process, I probably work it this way, (needed to test if work)
adding a 3 digits (001~999) in the beginning of the existing
part barcode number and use it as table index.
the first 3 digits are use to locate the record in one pass only. ReadTable Inventory, index
to keep the same 40 Kbytes table capacity
I have to decrease the part description from 16 to 13.
so when scanning a barcode part number eg: 001123456789012
( Record in the table : 001123456789012Baseball accepppppp019999 )
barcode 15 digits
__________________
001 123456789012 Baseball acce pppppp 01 9999
002 123456789013 Baseball cap pppppp 01 9999
____ ___________ _____________ ________ ___ ____
index description price Dept on hand
the rest of operations, will be to extract and build the table for the receipt and report.
receipt table with the description, quantity, price, adding taxes, total, payment for the receipt, and log this info in a table for future report.
the PIC18F27K42 already in transit
(all of this I'm guessing should produce something)
where can I find a complete GCBasic compiler manual reference
was looking for the word "inc" didn't find anything online on GCBasic.
know = "increase / increment" but was looking.
Thank's again for your help.
"parts data is actually static in a table."
the qty on hand will have to be adjusted on the fly.
Last edit: JB 2024-09-26
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
'inc'? The documentation is all in the Help. As you dig into thinks, like the structure of tables, will have to be added.
--‐--‐--------
If quality is required to be managed then you need a transaction log. So, write the log direct to the USB with only stock level local. Another table of 1200 items.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
We should move this conversation to Trello or Teams and post only updates here. This willbe long conversation and others do not need to see it all. :-)
A gift
I had existing code and I have adapted for you.
To find a part number that is 26 chars long, in a list of 1200 part numbers takes a between 0.061s to 0.067s
Where GetRecordNumber( searchstring ) returns the part number record, if 0 is return there is no part number. I have added GetRecordString() which gets the partnumber record.
I am testing on a mega4809 but I did compile for a 27K42. This took up 25% of program memory. This has 1200 records so that is not to bad.
I want to recommend that you add a CheckSum to the partnumbers. When the check sum of the part number chars in ASCII plus the checksum always equals 42. Why? If there is any corruption when loading or updating the databases then at a record level you will know something is not correct. You should always include a checksum anyway to ensure each and every transaction is valid ( you dont want someone changing data!).
See attached for the 1200 record search routines with checksum management.
7:45:52.703> Find Partnumber: 000000000001xxxxxxDDDDXXXX
7:45:52.703> Searching... Result
7:45:52.769> Record Number : 1
7:45:52.834> Part : 000000000001xxxxxxDDDDXXXX
7:45:52.834> CheckSum : A9
7:45:52.834>
7:46:11.830>
7:46:11.830> Find Partnumber: 100000000001xxxxxxDDDDXXXX
7:46:13.142> Searching... Result
7:46:13.142> Record Number : 0
7:46:13.204> Not part number: 100000000001xxxxxxDDDDXXXX
I found out that the life cycle of flash ram is about 1k,
here's the quote from: TRASTIKATA Proton Basic
"the flash cell write endurance for those devices (PIC18F27Q84) is rated only 1k write cycles and erasures in FLASH is done in 128b pages. If this is not acceptable, there's no point diving further into details, better use external FLASH memory with 100k endurance or better some NVRAM if higher write cycles is required."
it's look I'm better to use external flash memory as storage for the array
is there a way to add external flash or NVRAM IC, or is it too complicated
what is your input about it.
Last edit: JB 2024-09-27
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The table is a lookup for the prototype. Use this for now to build the prototype.
When you get the USB then we can look at loading into RAM , or,
We simply and some external VRRAM ( lots of options ) but all that will happen is to replace the READTABLE with another function to get the part information.
So, it is wrong to make the assume 'no point diving'. The function of getting the part data is not constrained by Readtable.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello everyone,
I'm looking to use a simple PIC, or AVR microcontroller as a RAM Flash Database
Here's some explication,
one of my project consist of a PIC that can search / access a RAM database kind of same as an old electronic
cash register (ECR)
basically I enter a pre-programmed part number , the PIC will search into the external flash Ram
and display it to an LCD screen. Then I can add quantity or tax sale to it.
Like an ECR
I'm not sure if it's is possible and what kind of command to use for a fast search into the flash ram to get the
job done, is there a database library that can do an accurate & fast search instead of a lookup function.
Anyway, I hope this request is clear to understand.
Thank's for any comments.
Nice solution.
Many questions mostly about the data/information to be used. This will determine the architecture.
Have you built a solution using ReadTable as a protoype? Was this approach too slow? What is the response expectation in terms of the time from partname entry to return of the price?
What LCD? Why not large GLCD?
This is a very exciting idea. Lots of architecture solutions come to mind. The answers to the questions will really help.
Using a PIC or AVR microcontroller to create a database for your project is definitely possible! Here are some steps and considerations to help you get started:
Last edit: Anobium 2024-09-25
Here's the breakdown for the part number records inventory.
(I need your direction on how to get this project to be fast and effective.)
Thank's again for your time and support.
Is the part number a fixed length? yes
What is the max length of the part number? 40 bytes (including all fields)
What is max price? and what, is it's length? 6 digits 9999.99
How many part numbers? 1000 max (fit on 64kb flash RAM)
Is any history of transactions required? yes, for sales reports
How should an invalid part number be handle? return "not found/invalid" if not programmed
Do you need to list part numbers? yes for sales reports
part number description price 6 digits link-dept 2 digits on hand
12 digits 16 characters xxxxxx DD XXXX
part record example: 123456789012abcdefghijklmnopxxxxxxDDXXXX
as for the table read, I did not write any code yet.
2 x serial LCD display (on hand)
LCD 2004 front operator display.
LCD 1602 back display.
timing and operation,
usually between scanning the barcode and displaying the info on the LCD screen
is less than 0.3 sec. (about the same as a regular ECR . )
the thermal receipt to be printed as shown below:
Store name ABC Store
Date / Time 9/12/2024 15:35
Clerk name + number Deby #555
---------------------------
Link Dept Hardware
part number 123456789123
Qty + unit price + ttl 2 @ $ 1.25 $ 2.50
---------------------------
Item Number Item 2
Sales Taxes Tax-1 $ 0.45
Tax-2 $ 0.24
Total Amount due Total $ 3.19 ---------------------------
Paid by Visa $ 3.19
**as for the report of sales: **
Store name ABC Store
Date / Time 9/12/2024 21:35
Clerk name + number Deby #555
---------------------------
Report Mode Z
Dept Hardware
QTY + Part number (2) 123456789012
Price each 2 @ 1.25 2.50
"
Item Number Item 2
---------------------------
Sub Total Sub-Total $ 2.50 Tax 1 Tax-1 $ 0.45
Tax 2 Tax-2 $ 0.24
Total Total $ 3.19
---------------------------
Payment Type Visa $ 3.19
*as for the hardware I'm looking to proceed like this *
Thank's for the code
I'll start coding.
as external flash ram memory,
witch one is a better choice and can be use with my Arduino uno R3
1: SPI SD Card module
2: 8-pin SPI Flash memory chip
I am just replying to other emails. But, I would recommend a USB interface - this can used on a PC for data management etc and the interface should work very well.
ok, then I'll order an SPI SD card module.
Thank's again.
One of these - https://www.amazon.co.uk/Read-write-Supports-Transfer-Interface-Communication/dp/B00XDLRL0U/ref=sr_1_1?crid=1ZP71YZ9N35BH&dib=eyJ2IjoiMSJ9.DGLtAvLrjUV3JjLQRp8uhmzlatUkG-Wfyz0bp6oFTobsvYdeOQbUZcQgaexa92pr3Ojom-Sc-HrAKCA1G2QoBCjvEpYKCVx5U63A1UjN1srpgMVekpWAPN7wpBift5ZfR_ewTDOntaYKn2IvCMHUuw.RgntJXCAQ-6gSmJFiBonIdhQgblSUC7CEqFMgQv52Ak&dib_tag=se&keywords=CH376+CH376S+IC+USB+Development+Board+Evaluation+Board&nsdOptOutParam=true&qid=1727287228&s=industrial&sprefix=ch376+ch376s+ic+usb+development+board+evaluation+board%2Cindustrial%2C86&sr=1-1-catcorr
Then, see https://sourceforge.net/p/gcbasic/discussion/629990/thread/e8b780e7f5/#23cd
Thanks for the information.
I would recommend a basic prototype using table(s)/readtable. This will prove the overall architecture. The storage/USB will need to be tested and resolved but with a hash then you should be able to retrieve the all part data and write the logs etc.
There will be much to do for you. But, start with a prototype using tables, then move to the USB data interface.
Let me think on this in the morning.
Take your time ,I'm not of any rush this project is on my bench for quite some time.
I just ordered 3 x CH376S Chip USB Host Interface modules to Aliexpress.
should be here around Oct 28.
Thank's again for your great support.
Last edit: JB 2024-09-25
Let me ask this,
my guess is:
So far to work with a 40 K bytes inventory table I have to use an USB Host + Flash drive
or maybe a ( PIC18F27K42T-I/SO with 128 K bytes cost around C$3.90 ) with a main program code under 70 k bytes to generate sales and reports.
when generating a daily report, I can create another internal table.
Let me know if the PIC can work the same.
Also an external file can be used as the table data source, can it be the same to export / save
the table back to a file.
Thank's again for your time.
Last edit: JB 2024-09-26
I would like to see/understand the architecture in a diagram. PowerPoint is good enough.
The online / offline state should be shown. One digram online and one diagram offline.
In terms of big chips... AVR mega2560. Not as cheap but it has a lot of Program memory.
Two diagrams please. If you need a draft diagram from me to help you then just ask.
Here's the diagram let me know if this is ok
offline : loading the ASCII file
online: Scanning, Displaying, Reporting
Also about searching in the table for a record, I add 3 digits (001~999) at the beginning of the part number like in house barcode and use it as a table index to locate in one pass the right record.
Still making some testing with this table index.
Last edit: JB 2024-09-26
Developing further.
What are the comms/protocols between the devices?
And, why not use a AVR2560? It is a the most powerful in terms of program space.
1 x RS232 barcode scanner
1 x serial 9600 baud thermal printer
2 x LCD Display serial or I2C I have both on hand
Why I pick a PIC18F27K42
because of Flash Ram of 128kbytes , 64Mhz clock, UART.
My estimation for the main program will never exceed 10 Kbytes + 40 Kbytes inventory + 5 Kbytes report table = 55 Kbytes at the most.
(just retrieving part code, send to display, and print receipt, and generate report .)
if the inventory table need to be adjusted, I can edit on the spot inside the PIC (I guess) or re-load from and existing ASCII file with a USB Host + Flash Drive.
I searched the GBBasic manual about table and didn't found any way to export/save the table.
Is it possible to export/save the table?
Thank's again
OK. I have updated the diagram.
You will need four USARTs. The K42 has two. I would still recommend the 2560.
I was going to ask about data management. I think I get the 40k and the other estimates but what functions are needed with the data?
Assume the parts are sorted in alpha order. You will need a clever lookup routine to ensure the look up does not take a long time. So, assume you add smaller tables to add the search otherwise the search would look up potentially 42 characters before a match happens.
The search could access a table that only has only the first ( say ) six chars. To find a part would be so much faster then once you have the parts that match the 6 chars then search a second table that has a hash for the all 42 chars. The search would only match a hash then you dont have to search 42 chars. But, this means more tables.
These are concepts to get the the results in a meaning time.
I am assuming that all the parts data is actually static in a table. And, you are only writing logs or transactions. You can allocate a DATA block to write to. Exporting would be a read of the DATA block to the USB, and, the same for the TABLE data.
You may want to allocate 1200 parts. Then, you import the parts from the USB to the table. The pre-allocation would be required as the table ( and DATA block) could have program or some other reference data before or after. But, importing the part data to an existing table is doable. When you import you just have following the format of the table structure. Pretty easy.
I still recommend a 2560. Starting with the K42 is ok as the code will be portable to another chip later.
This project will keep you busy.
as for the lookup search process, I probably work it this way, (needed to test if work)
adding a 3 digits (001~999) in the beginning of the existing
part barcode number and use it as table index.
the first 3 digits are use to locate the record in one pass only. ReadTable Inventory, index
to keep the same 40 Kbytes table capacity
I have to decrease the part description from 16 to 13.
so when scanning a barcode part number eg: 001123456789012
( Record in the table : 001123456789012Baseball accepppppp019999 )
the rest of operations, will be to extract and build the table for the receipt and report.
receipt table with the description, quantity, price, adding taxes, total, payment for the receipt, and log this info in a table for future report.
the PIC18F27K42 already in transit
(all of this I'm guessing should produce something)
where can I find a complete GCBasic compiler manual reference
was looking for the word "inc" didn't find anything online on GCBasic.
know = "increase / increment" but was looking.
Thank's again for your help.
the qty on hand will have to be adjusted on the fly.
Last edit: JB 2024-09-26
'inc'? The documentation is all in the Help. As you dig into thinks, like the structure of tables, will have to be added.
--‐--‐--------
If quality is required to be managed then you need a transaction log. So, write the log direct to the USB with only stock level local. Another table of 1200 items.
can it be written from the PIC, is there an USB command to write a file?
The post above gives insights. https://sourceforge.net/p/gcbasic/discussion/629990/thread/e8b780e7f5/#23cd
I don't have one of these device but you, hopefully, can write a transaction log.
Reading the parts may also be possible.
Lots to learn.
Many thank's
We should move this conversation to Trello or Teams and post only updates here. This willbe long conversation and others do not need to see it all. :-)
A gift
I had existing code and I have adapted for you.
To find a part number that is 26 chars long, in a list of 1200 part numbers takes a between 0.061s to 0.067s
7:53:08.703> Find partnumber: 000000000511xxxxxxDDDDXXXX
7:53:08.770> 511
7:56:43.453> Find partnumber: 000000000600xxxxxxDDDDXXXX
7:56:43.453> 600
7:57:42.515> Find partnumber: 000000000001xxxxxxDDDDXXXX
7:57:42.579> 1
Not bad. This uses a binary chop through the table of data.
Where GetRecordNumber( searchstring ) returns the part number record, if 0 is return there is no part number. I have added GetRecordString() which gets the partnumber record.
I am testing on a mega4809 but I did compile for a 27K42. This took up 25% of program memory. This has 1200 records so that is not to bad.
I want to recommend that you add a CheckSum to the partnumbers. When the check sum of the part number chars in ASCII plus the checksum always equals 42. Why? If there is any corruption when loading or updating the databases then at a record level you will know something is not correct. You should always include a checksum anyway to ensure each and every transaction is valid ( you dont want someone changing data!).
See attached for the 1200 record search routines with checksum management.
7:45:52.703> Find Partnumber: 000000000001xxxxxxDDDDXXXX
7:45:52.703> Searching... Result
7:45:52.769> Record Number : 1
7:45:52.834> Part : 000000000001xxxxxxDDDDXXXX
7:45:52.834> CheckSum : A9
7:45:52.834>
7:46:11.830>
7:46:11.830> Find Partnumber: 100000000001xxxxxxDDDDXXXX
7:46:13.142> Searching... Result
7:46:13.142> Record Number : 0
7:46:13.204> Not part number: 100000000001xxxxxxDDDDXXXX
Enjoy
Thanks so much for all your excellent work.
I found out that the life cycle of flash ram is about 1k,
here's the quote from: TRASTIKATA Proton Basic
"the flash cell write endurance for those devices (PIC18F27Q84) is rated only 1k write cycles and erasures in FLASH is done in 128b pages. If this is not acceptable, there's no point diving further into details, better use external FLASH memory with 100k endurance or better some NVRAM if higher write cycles is required."
it's look I'm better to use external flash memory as storage for the array
is there a way to add external flash or NVRAM IC, or is it too complicated
what is your input about it.
Last edit: JB 2024-09-27
The table is a lookup for the prototype. Use this for now to build the prototype.
When you get the USB then we can look at loading into RAM , or,
We simply and some external VRRAM ( lots of options ) but all that will happen is to replace the READTABLE with another function to get the part information.
So, it is wrong to make the assume 'no point diving'. The function of getting the part data is not constrained by Readtable.