May contain spoilers, both real and false.
Chapter 13.3: Straits --Display
Chapter 13.4: Straits -- Keyboard Decoding
"Much improvement last night."I chuckled and gave Julia's mom an air kiss on the cheek as I ducked in the door. "Somebody was peeking through the blinds?"
She just answered with a smile that might have been a little smug.
Julia came into the living room from the hallway, carrying her backpack on a shoulder. "I threatened to do all our kissing somewhere else, and Mom didn't even bat an eyelash," she complained.
"You two belong together. You can kiss anywhere." Mrs, Cisneros gave her daughter a quick hug and a kiss and sent us off with a "Have a good time studying together today."
I held the passenger-side front door of the Colt open and Julia climbed in.
She leaned around and put her backpack in the back seat as I went around and climbed in the driver's seat. "How about if I drive tomorrow?"
"Your folks don't need the car?"
I started the engine and the radio came on.
"Yeah. Well, I want to drive."
"Sure. I'll be waiting for you."
The radio played in the background as we talked about the day's schedule and other things.
"I don't like this song," she said as the radio played the chorus of Mary MacGregor's hit rendition of "Torn between Two Lovers".
"Mmmyeah. It does kind of get stuck in the head, and the lyrics aren't all that great."
Julia was silent for a moment, then asked, "Do you think it would be breaking rules to love two people?"
I had to think for a minute. "My automatic reaction is that's not the right kind of love if it's breaking any real rules."
Julia reached over to the radio and changed the station. The station she picked was playing Boston's "More Than a Feeling", and we listened to it in silence the rest of the way to school, holding hands on the gearshift lever.
*****
"Has anybody noticed that 24 bits of parallel I/O aren't enough to do both the keyboard and the displays?" I was sitting down in front of the computer when I asked this, and several hands raised.
"Two separate 68705s?" Bob asked.
I nodded. "The 24 bit I/O varient we are using, yeah, that would work."
Kyle laughed. "So we didn't need to bother with the timer and interrupts."
"We got 'em," Tim replied. "Might as well use 'em."
"Yeah," I agreed. "Especially in this little club or ours. But what else can we do besides using two separate controllers? Two controllers would have the disadvantage of needing either another port on the mainboard CPU, or some way of sharing a single port."
Jennifer and Bob discussed between themselves for a moment, then Jennifer turned around and said, "How many bits of I/O do we need?"
"Excellent question. Let's get our diagrams out, add the CPU interface, and count. Can you guys draw that on the board?"
The two of them went to the chalkboard, and shortly they had this up:
"Add a control line to the main CPU port for direction, maybe?" Bob suggested, and Jennifer did so.
Carlos asked, "Which are you going to use?"
"I'll ask Julia later. Before we get back to figuring out how to debounce the keyboard, what if this weren't the Micro Chroma 68? Could we use some other interface for the keyboard/status display controller?"
Chuck responded first. "Serial should work, right?"
"Does the 6805 have a serial port?"
"No, but can't we use a bit from the parallel port for it like the Color Computer does?"
"We can, indeed. Thank you. So, back to the debounce -- can we use the same timer setup that we're using for the display to sample the keyboard matrix and debounce it?"
----------------
I was going to ask first off if anyone had noticed that 32 pins of parallel I/O wasn't really enough, but, when Julia and I arrived, a group was gathered around Winston, where he was testing his keyboard and seven-segment displays. When he held a key down, it would interfere with the display.
He looked up at me. "I don't think we have enough output lines."
"Yeah, ...," I hedged.
Bob looked up, too. "I'm thinking we could add two 'LS138s and control them from port C to do the scanning, one for the displays and one for the keyboard matrix."
"Oh. That might work." I nodded absently. "Can we get a look at the problem before we go looking for solutions?"
"It's a bug." Winston half-asserted, half-asked.
"Oh, yeah. I was planning on looking at it first thing today when everyone comes. Can you do the explanation, Winston?"
"Why me?" he complained, half-joking, half-resigned, as he picked up his schematics and went to the chalkboard. He started by putting up the working diagram from the day before while we waited for more of the group to come.
When he was done, and most of our group was there, he looked at me and I nodded to Doctor Brown, and Doctor Brown said, "Any time you're ready."
Winston went back to his lab table and picked up his keyboard and controller, and announced, "Ground control, we have a problem."
Several of us chuckled as Winston proceeded to demonstrate how holding certain keys down would change a number on the display to something else.
"That's cool!" Carlos enthused.
"Solution one," Doctor Brown intoned. "It's not a bug, it's a feature."
Everyone laughed except Winston, who rolled his eyes before grinning lopsidedly. "That is one way of looking at it," he grudgingly admitted.
"Yeah," Doctor Brown grinned, "but I guess let's not use that solution this time."
"So, why does this happen?" I asked. "Show us what your circuit looks like."
Winston erased and redrew part of the circuit:
She hesitated, than suggested, "If we don't have that, how does the computer know what key the controller decoded?"
"Exactly. Thanks. So, Winston, now what's the problem?"
"We don't have enough bits of I/O, and I have used one of the buffers for the displays as one of the buffers for the keyboard matrix." He erased and redrew another part of the diagram to show what he had.
"I was hoping that the scan could be done quickly enough to not interfere, but just holding the keys down messes things up."
"So, Bob, you had a suggestion, right?"
"Jennifer thinks we should be able to do it without any additional parts, but I think we need two 74LS138s."
"Can you diagram that?"
"Well, first, I think we need another bit for the main CPU interface."
"Why's that?"
Jennifer replied, "Main CPU has to be able to tell the controller what it's supposed to do, so it needs at least one bit of control."
Bob and Jennifer worked quickly to put the following diagram up:
Bob modified parts of the diagram, to add the two demultiplexors:
"This would allow both the keyboard and the display to be accessed at the same time," Bob explained. "If I shut down the displays for a hundred microseconds or so, I can share the select lines, and save a couple of port bits."
"Okay. Now I think Jennifer is right that, with a bit of really careful timing, and a bit of care in how we set up the ports for the matrix and displays, we could reduce the interference so that you could hardly tell that holding a key down is causing stray LEDs to light. But it would be kind of sensitive to resistor values, and cheap parts might not work."
Jennifer looked a little put-out.
"I'm not saying she shouldn't do it, just that that there are trade-offs, and I'm not prepared to dig into that right now. Back to the 'LS138s, how do they affect our code? Bob and Jennifer, let someone else answer."
Bob and Jennifer both nodded in agreement.
Javier finally spoke up. "Instead of shifting the matrix strobe and the display select on their ports, we count them?"
"Good. What does the counting look like?"
Everyone thought for a bit, and then Javier answered: "Counting for one of those can be just an INC instruction, but the other is going to be adding sixteen or something, depending on the bits used, right?"
"Exactly. So we'll look at that, but anyone have another way to do this?"
Mike said, "I'm planning on sharing a port between the keyboard and the displays, but I'll use a single eight-bit buffer to disable the keyboard when I'm using the displays. I'll use the extra bit from the display select port to shut off the keyboard matrix except when I'm reading it."
"How about the control line for the main CPU?"
"The Micro Chroma 68 keyboard interface only uses seven bits of data, so that leaves one bit that can be used as a strobe or control signal. I think that'll be enough." Mike stood up to a blank panel and sketched out his idea.
"Very good. Now we have at least a couple of different approaches that might work."
Larry asked, "Would it work to use two 6805s?"
"What do you think?"
"I guess we'd need a way for the main CPU to talk to the second controller."
"Sure. And that may have some advantages, as well."
Kyle laughed. "So we wouldn't need to bother with the timer and interrupts."
"We got 'em," Tim replied. "Might as well use 'em."
Terry asked, "How about using a serial port for talking to the main CPU?"
"The Micro Chroma 68 design is looking for the keyboard on a parallel port," I explained. "But if we modify the design and the monitor ROM, we should be able to get a serial interface to work, as well."
Chuck objected, "The 6805 doesn't have a serial port."
"True."
After a moment of thought, he said, "But I guess a single bit of a parallel port could work, the way it's done on the Color Computer."
"Bit-banging. We could put the 6805's bit operators to good use there, I think."
Carlos asked, "Which are you going to use?"
"I'll ask Julia later."
Several of the group chuckled.
"Because it's her keyboard, not mine."
Lupe raised a question -- "Does the Micro Chroma 68 use the status display?"
"Not with the current software, but, again, we can modify the software to use it."
"Then maybe we don't really want the display on the keyboard controllers we're building now?"
"That is definitely a design option," I concurred. "Or, if you want the display but want to do it another way, you could add a 6821 to the mainboard and have the mainboard CPU control it directly."
Tanya complained, "So, basically, for the last three days, we've been on a wild goose chase."
"Exploring options," I reinterpreted. "And learning how to use a timer interrupt, so we can use timed samples instead of riding the port to debounce the keyboard matrix. And looking deeper into what we might want to build."
Larry said, "Okay. Can we get back to debouncing the keyboard, now? Can we use the same timer setup that we're using for the display to sample the keyboard matrix and debounce it?"
"Explain."
"The whole point of the debounce is to be sure we read one keypress as one keypress? We could remember which key we saw in a variable, and check it on the next timer interrupt?"
"How long do we wait to accept a keypress?"
Julia recited, "300 words per minute is five words per second. At six letters per word, that's thirty keys pressed a second, or one thirtieth of a second."
Terry added, "That's about thirty-three milliseconds, so it's about thirty-three interrupts."
Freddie asked, "Can a key bounce take more than a millisecond to settle?"
Suzanne suggested, "We can count interrupts to time a keypress. Maybe sixteen interrupts is good to call it debounced."
I added, "We can experiment with that, and we might even want to add keyboard repeat functions based on counting timer interrupts."
Discussion of multiple simultaneous keys pressed.
State is sparse matrix -- matrix algebra
"Good, but let's think about it a bit further. What if we want to see keys that repeat?"
"We'd need to time it."
Suzanne suggested, "We could count interrupts as a way to time it?"
"Yep. Next question, what if we press one key, then another before we release the first? Can we figure out a way to let the keyboard key rollover, so to speak, to the next key?"
"Have some sort of memory buffer?" Terry suggested.
---------------
Then Carlos asked, "Okay, we've recorded all this state, now what?"
"How do we check to see if something changed?"
From there we talked about using the interrupt counter to tell when we needed to check whether the state had changed, and the about using bit masking and bit counting to tell which keys had been pressed and released, and so forth.
And somebody pointed out that the state table naturally kept track of key rollover, so we talked about adding a type-ahead buffer.
I had to leave to deliver newspapers, and, by the time I got back, Winston, Jeff, and Mark had their keyboards working with their Micro Chroma 68+6801s. Bob, Jennifer, Mike, also had their keyboards working, and those who had theirs working were going around helping others.
Suzanne had joined Julia, so I sat down with them and we got both of their keyboards working and interfaced with their Micro Chroma 68+6801s before time to shut down.
*****
"I need to make a stop in the library." I helped Julia wrap her computer in aluminum foil for protection.
"Can I come with?"
"Well, of course."
*****
"Intel 8086? What do you need that for?"
"Ammunition."
*****
After studying and singing, Julia played with her Micro Chroma 68+6801 while I studied the i8086/8088 manual and the TMS 9900 and 9940 manuals.
When I took her home and we shared a quick kiss on her doorstep, her mother opened the door and cleared her throat.
"Mom, not tonight. I've been studying stuff that is completely foreign to me. Joe calls it playing, but I'm tired."
"I have to admit to being a bit tired myself," I added. "Julia's keyboard is now talking to her computer. Tomorrow's going to be another long day, I think."
"Speaking of her computer," Mr. Cisneros spoke up from the couch, "I think she needs a box to put it in."
"True."
I went in and sat down, and we discussed plans for an enclosure for her computer. We talked about a box like mine, and we also talked about putting her keyboard in a separate enclosure so she move it around, and several other options, sketching up some plans, but making no decisions.
---------------
Lupe raised a question -- "Does the Micro Chroma 68 use the display?"
"Not with the current software, but we might ft ."
"Then maybe we don't really want the display on the keyboard controllers we're building now?"
"That is definitely a design option," I concurred. "Or, another way to add a display, you could add a 6821 to the mainboard and have the mainboard CPU control it directly."
Tanya complained, "So, basically, for the last three days, we've been on a wild goose chase."
"Exploring options," I reinterpreted. "And learning how to use a timer interrupt, so you can use the timer interrupt method of decoding the keyboard matrix. Or taking a side-tour to start designing a trainer."
Larry said, "Okay, let's get back to debouncing the keyboard. I guess we can use the same timer setup that we're using for the display to sample the keyboard matrix and debounce it?"
"Explain."
"The whole point of the debounce is to be sure we read one keypress as one keypress? We could remember which key we saw in a variable, and check it on the next timer interrupt?"
"Good, but let's think about it a bit further. What if we want to see keys that repeat?"
"We'd need to time it."
Suzanne suggested, "We could count interrupts as a way to time it?"
"Yep. Next question, what if we press one key, then another before we release the first? Can we figure out a way to let the keyboard key rollover, so to speak, to the next key?"
"Have some sort of memory buffer?" Terry suggested.
----------------
"In my ideal world, people could be lovers without having, you know, sexual relations."
"Do you think it would make it alright, to be torn between two uhm, platonic lovers? I don't think that even makes sense as a question."
"Heh. I'm not a fan of the song, either, but, like a jingle for fast food, it gets stuck in the brain."
picking julia up in the morning, talk about exercise, julia says she will drive Wednesday (but does not say reason is to to arrive early and exercise with Joe)
in lab, discussing how to deal with needing 8 more port lines because of seven segment display,introduce ls138
The doorbell rang as I was changing into gym shorts and a tee shirt for my morning exercises.
Giselle called out, "I think you should get it, Joe."
Puzzled, I pulled my tee on and carried my gym shoes into the living room.
Julia was waiting at the screen door in exercise gear when I rounded the hall doorway into the living room.
"Oh. So that's why you wanted to drive today. You wanted to come early and see what I do for exercise?" I gave her a cheesy grin and went to the door, ligting the screen door latch so she could come in.
"Well, more to join you than to watch." She loosened her shoelaces and left her shoes inside the door as she came in.
I set my shoes by hers. "I could have gone to your house early."
"And exercise with my parents watching? No way. Not the first time we exercise together. How do you usually start?"
"Warmups and stretches. The carpet in here is easy on the bones, but can slide about underfoot. The floor in the den is hard, but it doesn't slide you unless you're wearing socks."
"Barefoot it is, then."
We both left our socks on our shoes, saying good morning to my mom on our way through the kitchen to the den.
"You two focus on your exercises and I'll fix breakfast this morning."
Mom must have also been in on the plan.
We faced each other in the middle of the den. "And?" Julia looked at me expectantly.
"Uhm, I usually start with plié to warm up. Other than that, it's pretty random, and I'm open to suggestions."
"Ballet?"
"I learned a little from Louise and Giselle. I wanted to take a class in modern dance this semester, but they told me I already had more than the usual limit of credit hours."
She laughed. "You work too hard. I've picked up some things from creative dance classes."
For about ten minutes, we shared ideas about warmups and stretches.
I showed her the first three minutes of NHK rajio taisō, the Japanese public broadcasting system's radio (and TV) exercise routine. (You can probably find videos of people doing it, by searching for "NHK Rajio Taisō".)
"The hands and legs are opposite of plié."
"Yeah. In ballet's Plié, the beat of the hands and legs is in opposition, but in rajio taisō, they start together and beat in the same direction."
"So you learned all this dance from Louise?"
"And Giselle. I wanted to take a class in modern dance this term, but there was no time for it."
"Let's take it together."
"I wonder if I'll have time for summer classes, with the internships. I thought you were moving on to Texas Christian."
"Mom thinks I should postpone the associate's degree."
"You need to do what you need to do."
She didn't look happy with that thought.
"Of course, if that happens to be sticking around and doing undergraduate work at UTPB with me, that might work, too."
"Can you study your Japanese at UTPB?"
"Nope. Push-ups and sit-ups?"
"Sure. What'll you do about Japanese?"
"I should probably talk to somebody at UT or BYU about correspondence work."
Our conversation lagged for a couple of minutes while we focused on the exercises.
"Up for a run?"
"Sure."
"Want to run past your house? I think we can make it in ten minutes. I think you can borrow the shower on my parents' side of the house to wash the swe-- glow off."
She laughed. "That might make my mom's day. And I already checked with you mom on the shower."
"Glad somebody here is good at planning."
We told my mom we'd be back in ten and headed out the front door, running north to cross 42nd at Dixie Boulevard, then past the shopping center to run along the south edge of the park. We rounded her block, stopping at her house to say hi to her mom, then back around her church, following Lindale back to the intersection with 42nd, where Lindale turns into 38th, then followed 38th home.
Mom made sure Julia had what she needed for her shower, and I took a quick shower in the bath on Giselle's and my side of the house, and we packed our stuff in her car and headed to school.
Mention of the trip to the surplus store for disk drives, everyone plans to go, plans for picnic?
Framework makes debouncing easy
Having to use the anodes port for the column strobes? Add one-of-eight selects instead?
Using the interrupt input for system request
****
"We want to be able to have the CPU do other things besides display numbers, so we're going to use the timer built into the 6805 to count instead of having the CPU count, and we'll have the timer interrupt the program to actually display the numbers."
"Is this only for displaying numbers?" Tanya asked in a slightly petulant tone.
"Well, the numbers might mean things. For instance, if something goes wrong during boot, we could put an error code and an address on the display, to give clues about the error state. Or we might say that a blank display is an all-operational status."
I can tell your eyes are glazing over now, so, rather than walk you through it with us I'll just note that we read in the manual about the timer, and I walked them through initialization, using the pre-scaler to set the granularity, calculating the value to initialize the timer and pre-scaler to interrupt the CPU once every millisecond, and constructing the interupt routine to display the digits one place at a time.
Someday, somewhere in my blogs, I'll show the complete keyboard debounce and status display routine, complete with display suppression and other features that we evenutally added. Suffice it to say that we had Julia's status display functional at a usable level on Monday before I went home to deliver newspapers, and that about half of the group had theirs functional by the time I got back.
Tuesday I explain that we need more computers running, so Julia's is not just Julia's. Then we forge ahead into the keyboard decoding.
Wednesday, while students are catching up, Julia, Mark, Jeff, Winston, and Suzanne dig in and get their computers ready for RAM, ROM, burners, disk controllers, etc., while I study the Forth manual and the TMS 9940 datasheets.
Which is what we did. Again, Doctor Brown let them work while I was delivering my newspapers, and Julia, Mark, and Jeff helped those who needed help with the tools on the Micro Chroma 68.
About half of the group had their display routines working well by the time I returned to pack things up.
From Monday to Wednesday, in lab, I let the others work while I helped Julia program her keyboard controller. Someone was watching over our shoulders as we worked, and the structure of the code made the rounds -- the interrupt handlers, the state tables for the keyboard matrix, the translation matrix for the LEDs, etc.
Bob and Jennifer pretty much got it worked out for themselves, and we compared notes.
Mark, Jeff, and Mike picked up what we were doing, and also had their keyboard controllers working shortly after Bob, Jennifer, and Julia and I had ours working.
It's tempting to go into great detail on the keyboard decoding and the status display. Maybe, one day, I'll write a book on how to do it with parts you can buy now. 6805s are kind of hard to get now. (It would fill an entire book, yes.)
I'll note that I walked the group through several ways of keeping keyboard state for use in debouncing. Some of the students understood when I
Pascal, book of Ether, keyboard with Julia
Ed Snyder's black stealth keyboard
monday
Julia and I work out the keyboard and seven-segment status display
class also progressing, work on 68705 trainer monitor
home evening with Julia's family and missionaries, second discussion,
recital practice every evening all week
tuesday, wiring Julia's with memory switches, DMA controller, ROMs, full RAM
continued work on trainer monitor
communicating with TSC about drivers
(evening?)
wednesday,
Julia's EPROM/MCU burners, my daughterboard starts
class continues with trainer monitor, etc.
her scripture study group
thursday,
diagramming,
first peek at forth
class completes trainer monitor.
our institute
friday,
trip to austin
meeting with motorola, Julia asked to join
discussion of
-- floppy controllers
-- 2801 address spaces, I/O based memory banking, call stack cache
-- RISC concepts
-- 2809 similar to 2801
-- 31609 with 32 bit addressing
-- 38000 with stack caching
saturday
Julia's disk drives
(Nos) besaremos cuando y como queramos.
cuándo y cómo
Trip back, too much heavy kissing, discussion of information sharing?
Managers and bishops who don't know what to do with information that comes up.
(In notes for bringing up flex:)
Denny called about the time we were wrapping up, and Julia got on the extension in Dad's study to say hi. It seemed it would be appropriate to make a run to Austin the next weekend, and to leave immediately after our last morning classes so I could visit with some of the management at Motorola Friday evening.
"You, know," Julia said, "if I went with, maybe I could look for floppy disk drives at that surplus shop on Saturday before coming back."
Denny checked with Denise, and they decided Julia could sleep on the couch in the living room and I could sleep on the floor in a sleeping bag in the boys' room. Julia's parents said they thought it would be okay, and Mom and Dad suggested we pray about it.
Which we did. No one felt inspired to object,
Julia suggested she go with me, so she could go looking for her own disk drives.
Talk about duty cycle and mention DtoA as a way to adjust brightness.
Julia returned to working on her keyboard/trainer, while I dug back into my test routines.
Watching the students work on the keyboard and keypad matrix decoding, became clear to me that, while the bit I/O instructions might be useful for certain singular, non-generalized kinds of code, a keyboard or keypad matrix contained a lot of repeated elements. Ultimately, shifts and logical instructions would provide the more general scalable solution.
I stood up and demonstrated the concept of a state array for the matrix, then suggested we put it on a back burner and look at the seven-segment LED displays. This time, the bit I/O instructions were ignored, and several groups formed around defining an array of the segment patterns for each integer. Some of the students wanted to turn the translation array upside down for some reason, but I didn't stop them.
Suzanne's and Winston's and Winston's mainboards were both up enough to display the TV-BUG prompt by this point, and the four of them joined the rest on the keyboard/trainers.
It's tempting to go into great detail on the keyboard decoding and the status display. Maybe, one day, I'll write a book on how to do it with parts you can buy now. 6805s are kind of hard to get now. (It would fill an entire book, yes.)
I'll note that I walked the group through several ways of keeping keyboard state for use in debouncing. Some of the students understood when I
Since Flex was running on my Micro Chroma 68, I was able to load the cross-assembler, and we had several students burn code into their 68705s for testing before time to shut down.
Mike kept trying to work out how to set the keyboard state up as an array, but he couldn't seem to quite pin it down.
I shook my head, and she led me out the back door. There was a large tree with a tire swing
I guess there were no surprises on Sunday, unless you would consider it surprising that Pat and George attended Julia's congregation again. They slipped out before we could talk with them. We didn't see Mike.
Or you might consider it surprising that Julia and I joined the choir in my ward, preparing for Easter Sunday. No?
I suppose it would be no surprise that Julia insisted on calling Denny and Denise to ask if there were room for her to stay overnight Friday. With a bit of discussion, it was determined that she could have the couch in their living room, and I would roll a sleeping bag out on the floor of the boys room, and both our parents approved that plan.
That Sunday was about as one might expect, I think. In the morning, I visited Julia's congregation. Pat and George came and sat in the back. Mike slipped in before the sermon started, and all three slipped out before we had a chance to talk with them.
In the afternoon, Julia visited mine. This time, she joined our choir practice in between meetings and young adult family home evening.
I told her about needing to go to Austin before her meetings, and by the time we were finished with mine, she had decided she was going with me.
"Floppies multiplying like rabbits," I grumbled.
She laughed.
tendency to idealize/idolize foreign
Chapter 13.5: what?
[Backed up at .]
No comments:
Post a Comment
Keep it on topic, and be patient with the moderator. I have other things to do, too, you know.